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

NaN value in an array add unexpected comma #499

Closed
1 task done
AKA-MMM opened this issue Apr 3, 2024 · 2 comments · Fixed by microsoft/vcpkg#38532
Closed
1 task done

NaN value in an array add unexpected comma #499

AKA-MMM opened this issue Apr 3, 2024 · 2 comments · Fixed by microsoft/vcpkg#38532

Comments

@AKA-MMM
Copy link

AKA-MMM commented Apr 3, 2024

Hi,
I'm trying to serialize an array with the values [0, 2, NaN, NaN] to obtain a JSON Array representation. For this, I have configured the encoder as follow:
` jsoncons::basic_json_options options;

options.nan_to_str("NaN");

options.inf_to_str("Inf");

options.neginf_to_str("NegInf");

m_encoder= new jsoncons::compact_json_stream_encoder(p_io, options);

`
So, I expect the following result: [0, 2, "NaN", "NaN"]. But, the obtained result is [0, 2, "NaN",,"NaN"]. E.g. I have an unexpected comma between the two strings "NaN". Without the options, the result is [0, 2, Null, Null] (no unexpected comma). This difference comes from the way NaN (and also infinities) are managed. Without option (or with the option nan_to_num), visit_double() just add the "Null" string by sink.append. With the option nan_to_str, visit_double() calls visit_string(). Hence visit_string() adds a first comma. And visit_double() adds the second comma.

  • Latest release 0.173.4
@AKA-MMM AKA-MMM added the Bug label Apr 3, 2024
@danielaparker
Copy link
Owner

Thanks for reporting this, we'll look into it.

@danielaparker
Copy link
Owner

Fixed on master

data-queue pushed a commit to microsoft/vcpkg that referenced this issue May 3, 2024
<!-- If your PR fixes issues, please note that here by adding "Fixes
#NNNNNN." for each fixed issue on separate lines. -->

Fixes danielaparker/jsoncons#502
Fixes danielaparker/jsoncons#501
Fixes danielaparker/jsoncons#499
Fixes danielaparker/jsoncons#496
Fixes danielaparker/jsoncons#493
Fixes danielaparker/jsoncons#490

<!-- If you are still working on the PR, open it as a Draft:
https://github.blog/2019-02-14-introducing-draft-pull-requests/. -->

<!-- If this PR updates an existing port, please uncomment and fill out
this checklist:

- [x] Changes comply with the [maintainer
guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md).
- [x] SHA512s are updated for each updated download.
- [x] The "supports" clause reflects platforms that may be fixed by this
new version.
- [x] Any fixed [CI
baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt)
entries are removed from that file.
- [x] Any patches that are no longer applied are deleted from the port's
directory.
- [x] The version database is fixed by rerunning `./vcpkg x-add-version
--all` and committing the result.
- [x] Only one version is added to each modified port's versions file.
yurybura pushed a commit to yurybura/vcpkg that referenced this issue May 8, 2024
<!-- If your PR fixes issues, please note that here by adding "Fixes
#NNNNNN." for each fixed issue on separate lines. -->

Fixes danielaparker/jsoncons#502
Fixes danielaparker/jsoncons#501
Fixes danielaparker/jsoncons#499
Fixes danielaparker/jsoncons#496
Fixes danielaparker/jsoncons#493
Fixes danielaparker/jsoncons#490

<!-- If you are still working on the PR, open it as a Draft:
https://github.blog/2019-02-14-introducing-draft-pull-requests/. -->

<!-- If this PR updates an existing port, please uncomment and fill out
this checklist:

- [x] Changes comply with the [maintainer
guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md).
- [x] SHA512s are updated for each updated download.
- [x] The "supports" clause reflects platforms that may be fixed by this
new version.
- [x] Any fixed [CI
baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt)
entries are removed from that file.
- [x] Any patches that are no longer applied are deleted from the port's
directory.
- [x] The version database is fixed by rerunning `./vcpkg x-add-version
--all` and committing the result.
- [x] Only one version is added to each modified port's versions file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants