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

json2dict converts unquoted true and false to numerical boolean #38

Closed
ramikhaldi opened this issue Sep 30, 2021 · 6 comments
Closed

json2dict converts unquoted true and false to numerical boolean #38

ramikhaldi opened this issue Sep 30, 2021 · 6 comments

Comments

@ramikhaldi
Copy link

ramikhaldi commented Sep 30, 2021

The json2dict treats the unquoted string values true and false as boolean and converts them to 1 and 0.
Example:
{
"valueTrue": true,
"valueFalse": false
}

will be converted to:

valueTrue 1 valueFalse 0

Is there any configuration to prevent that ?

Thanks in advance!

@bovine
Copy link
Member

bovine commented Sep 30, 2021

That's an interesting observation. In general, we've tried to make the yajl::json2dict function perform identically to the same one provided by the json package, except faster. However, this is indeed an unintended difference in behavior:

package require json

::json::json2dict {{
"valueTrue": true,
"valueFalse": false
}}

valueTrue true valueFalse false

@bovine
Copy link
Member

bovine commented Sep 30, 2021

I think changing the replacements in parse2dict_boolean_callback might fix this behavior? https://github.com/flightaware/yajl-tcl/blob/master/generic/yajltcl.c#L227

@ramikhaldi
Copy link
Author

Thanks @bovine for your response, I also have seen that location but I was not sure if there might be other side effects when fixing it. As there are already tests for the library, we can rerun the tests and see if something has been broken. I will recompile the library and check.

@ramikhaldi
Copy link
Author

@bovine I have performed a pull request. Let's see the test results in the ci..

@ramikhaldi
Copy link
Author

Can you please approve the waiting workflows (#39)? Thanks.

@bovine
Copy link
Member

bovine commented Jan 19, 2024

That PR has been merged and released as v1.8.1

@bovine bovine closed this as completed Jan 19, 2024
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

2 participants