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

Probably Invalid json generated if arr of tuples key is number #66

Open
inv2004 opened this issue Mar 16, 2023 · 2 comments · May be fixed by #67
Open

Probably Invalid json generated if arr of tuples key is number #66

inv2004 opened this issue Mar 16, 2023 · 2 comments · May be fixed by #67

Comments

@inv2004
Copy link

inv2004 commented Mar 16, 2023

import jsony
echo {"aaa": 100}.toJson()
# {"aaa":100}
echo {100: "aaa"}.toJson()
# [[100,"aaa"]]

Probably it is ok, but a bit inconsistent

@inv2004 inv2004 changed the title Probably Invalid json generated if arr of tupples key is number Probably Invalid json generated if arr of tuples key is number Mar 16, 2023
@pietroppeter
Copy link
Contributor

I am actually more surprised by the first (I think it should be incorrect) than the second example. 😁

IIRC the brackets syntax should be equivalent to array of tuples.

@inv2004
Copy link
Author

inv2004 commented Mar 17, 2023

I see special conversion for the type in code, it looks good, but, unfortuantely, in Nim it is still array

And looks like there are two problems around it:

json key's duplicates are not prohibited, but not recommended

{"a":10, "a":100}.toJson
# {"a":10,"a":100}

it does not work:

let x = {"a": 100}
echo x.toJson().fromJson(typeof x)
# Expected [ but got { instead

inv2004 added a commit to inv2004/jsony that referenced this issue Mar 17, 2023
@inv2004 inv2004 linked a pull request Mar 17, 2023 that will close this issue
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 a pull request may close this issue.

2 participants