Skip to content

Properly handle JSON encoding for Bytes and Date in primitives #915

@raararaara

Description

@raararaara

What happened:
The current implementation of the toJSON method does not account for the JSON encoding of Bytes and Date types in the primitives. This omission can lead to incorrect serialization of these data types when they are expected to be properly formatted in JSON.

/**
* `toJSON` returns the JSON encoding of the value.
*/
public toJSON(): string {
if (this.valueType === PrimitiveType.String) {
return `"${escapeString(this.value as string)}"`;
}
// TODO(hackerwins): We need to consider the case where the value is
// a byte array and a date.
return `${this.value}`;
}

What you expected to happen:
The toJSON method should return a well-formed JSON representation for Bytes and Date, ensuring proper serialization of these types when used.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

  • Yorkie JS SDK version: 0.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions