# Serializers

**@node-ts/bus-core** by default uses a naive serializer that leverages the built-in `JSON.parse()` and `JSON.stringify()` functions. This is used to convert messages to a serialized form when publishing them to the transport, and then deserializing them when they're read from the transport.

While this is fine for the simplest of cases, it suffers from the normal problems of deserializing into strong types.&#x20;

For example consider the following message

```typescript
import { Command } from '@node-ts/bus-messages'

export class RegisterUser extends Command {
  constructor (
    readonly dateOfBirth: Date
  ) {}
}
```

If this is run through the default serializer the effect will be the same as:

```typescript
const command = new RegisterUser(new Date())
const plainCommand = JSON.parse(JSON.stringify(command))
plainCommand.getDate() // ERROR - getDate() does not exist on plainCommand
```

The default serializer is not recommended for serious projects given these limitations, and [class serializer](/guide/serializers/class-serializer.md) should be used where possible.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bus.node-ts.com/guide/serializers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
