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

RFC 8259 compatibility mode #554

Closed
Harvie opened this issue Mar 12, 2020 · 3 comments
Closed

RFC 8259 compatibility mode #554

Harvie opened this issue Mar 12, 2020 · 3 comments

Comments

@Harvie
Copy link

Harvie commented Mar 12, 2020

Hello,
do you think it would be possible to add compatibility mode to enforce JSON output strictly corresponding to standard of choice? eg. RFC 8259.

We have issues that json-c is generating JSON code containing NaNs, which is possible in ECMA, but not in RFC. Using null in such case might make sense.

@dota17
Copy link
Member

dota17 commented Mar 12, 2020

  1. ECMA doesn't support NaN

Number: a signed decimal number that may contain a fractional part and may use exponential E notation, but cannot include non-numbers such as NaN.
https://en.wikipedia.org/wiki/JSON

  1. json-c will report error "null expected" when it parse "NaN" in STRICT mode. Maybe you use it in wrong way?

@hawicz
Copy link
Member

hawicz commented Mar 13, 2020

While there's a strict mode when parsing json, there is generally no validation if you're working with json_object's, nor when a tree of json_object's is serialized into a json string.
I suppose one option would be to fail (crash?) if you call json_object_new_double() that way.
Or, we could add a "strict output" flag to json_object_to_json_string_ext(), but then we'd also need to add some way to indicate where in the tree it failed.
Neither one of these seems like a good option. Instead, I'd say that if you don't want NaN in the output, don't call json_object_new_double(NAN).

@dota17
Copy link
Member

dota17 commented Apr 2, 2020

The problem has already been solved

@dota17 dota17 closed this as completed Apr 2, 2020
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

No branches or pull requests

3 participants