Skip to content

Conversation

@bhufmann
Copy link
Contributor

@bhufmann bhufmann commented Mar 30, 2022

What it does

Add utility to support json stringify/parse with JSONBigInt.

Example Usages:

// Usage with normalizer
import { Experiment } from 'tsp-typescript-client/lib/models/experiment';
let input = JSONBigUtils.stringify(experiment);
let output: Experiment = JSONBigUtils.parse(input, Experiment);

// Usage no normalizer
input = JSONBigUtils.stringify(inputObj);
output = JSONBigUtils.parse<string>(input);
input = JSONBigUtils.stringify(BigInt("1234567890123456789"));
output = JSONBigUtils.parse<bigint>(bigIntInput);

fixes #57

How to test

Unit tests including new tests for utility successful.

Follow-ups

N/A

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Signed-off-by: Bernd Hufmann [email protected]

@bhufmann bhufmann marked this pull request as draft March 30, 2022 14:03
bhufmann added a commit to bhufmann/vscode-trace-extension that referenced this pull request Mar 30, 2022
TODO: JSONBig.parse() create bigint if numbers are small. This has to
be addressed when deserializing messages. Re-use tsp-typescript-client's
normalizer to do that.

The following branch in the tps-typescript-client is introducing an
utility class and, if accepted, it can be used to solve the
deserialization issue:

eclipse-cdt-cloud/tsp-typescript-client#56

Signed-off-by: Bernd Hufmann <[email protected]>
bhufmann added a commit to bhufmann/vscode-trace-extension that referenced this pull request Sep 14, 2022
TODO: JSONBig.parse() doesn't create bigint if numbers are small. This
has to be addressed when deserializing messages. Re-use the normalizer
of the tsp-typescript-client to do that.

The following branch in the tps-typescript-client is introducing an
utility class and, if accepted, it can be used to solve the
deserialization issue:

eclipse-cdt-cloud/tsp-typescript-client#56

Contributes to fixing eclipse-cdt-cloud#35

Signed-off-by: Bernd Hufmann <[email protected]>
bhufmann added a commit to bhufmann/vscode-trace-extension that referenced this pull request Sep 15, 2022
TODO: JSONBig.parse() doesn't create bigint if numbers are small. This
has to be addressed when deserializing messages. Re-use the normalizer
of the tsp-typescript-client to do that.

The following branch in the tps-typescript-client is introducing an
utility class and, if accepted, it can be used to solve the
deserialization issue:

eclipse-cdt-cloud/tsp-typescript-client#56

Contributes to fixing eclipse-cdt-cloud#35

Signed-off-by: Bernd Hufmann <[email protected]>
bhufmann added a commit to bhufmann/vscode-trace-extension that referenced this pull request Sep 16, 2022
TODO: JSONBig.parse() doesn't create bigint if numbers are small. This
has to be addressed when deserializing messages. Re-use the normalizer
of the tsp-typescript-client to do that.

The following branch in the tps-typescript-client is introducing an
utility class and, if accepted, it can be used to solve the
deserialization issue:

eclipse-cdt-cloud/tsp-typescript-client#56

Contributes to fixing eclipse-cdt-cloud#35

Signed-off-by: Bernd Hufmann <[email protected]>
bhufmann added a commit to bhufmann/vscode-trace-extension that referenced this pull request Sep 22, 2022
TODO: JSONBig.parse() doesn't create bigint if numbers are small. This
has to be addressed when deserializing messages. Re-use the normalizer
of the tsp-typescript-client to do that.

The following branch in the tps-typescript-client is introducing an
utility class and, if accepted, it can be used to solve the
deserialization issue:

eclipse-cdt-cloud/tsp-typescript-client#56

Contributes to fixing eclipse-cdt-cloud#35

Signed-off-by: Bernd Hufmann <[email protected]>
bhufmann added a commit to eclipse-cdt-cloud/vscode-trace-extension that referenced this pull request Sep 23, 2022
TODO: JSONBig.parse() doesn't create bigint if numbers are small. This
has to be addressed when deserializing messages. Re-use the normalizer
of the tsp-typescript-client to do that.

The following branch in the tps-typescript-client is introducing an
utility class and, if accepted, it can be used to solve the
deserialization issue:

eclipse-cdt-cloud/tsp-typescript-client#56

Contributes to fixing #35

Signed-off-by: Bernd Hufmann <[email protected]>
@bhufmann bhufmann force-pushed the serialize_util branch 2 times, most recently from 868448c to 238dfa3 Compare June 20, 2023 21:14
@bhufmann bhufmann changed the title Add utility to support json serializtion/deserialization with Add utility to support json stringify/parse with JSONBigInt Feb 13, 2025
@bhufmann bhufmann force-pushed the serialize_util branch 2 times, most recently from 58fcbda to fe3ba59 Compare February 13, 2025 01:58
@bhufmann bhufmann marked this pull request as ready for review February 13, 2025 01:59
fixes eclipse-cdt-cloud#57

Example Usages:

// Usage with normalizer
import { Experiment } from
'tsp-typescript-client/lib/models/experiment';
let input = JSONBigUtils.stringify(experiment);
let output: Experiment = JSONBigUtils.parse(input, Experiment);

// Usage no normalizer
input = JSONBigUtils.stringify(inputObj);
output = JSONBigUtils.parse<string>(input);
input = JSONBigUtils.stringify(BigInt("1234567890123456789"));
output = JSONBigUtils.parse<bigint>(bigIntInput);

Signed-off-by: Bernd Hufmann <[email protected]>
Copy link

@MatthewKhouzam MatthewKhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@bhufmann bhufmann merged commit bdb337d into eclipse-cdt-cloud:master Mar 6, 2025
7 checks passed
@bhufmann bhufmann deleted the serialize_util branch March 6, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add utility to support json serialization/deserialization with JSONBigInt

2 participants