Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
raararaara opened this issue Oct 23, 2024 · 0 comments
Open

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

raararaara opened this issue Oct 23, 2024 · 0 comments
Labels
bug 🐞 Something isn't working

Comments

@raararaara
Copy link
Contributor

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
@raararaara raararaara added the bug 🐞 Something isn't working label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant