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

Slight incompatibility between LazyJSON.Object and JSON3.write #12

Open
ninjaaron opened this issue Aug 7, 2019 · 2 comments
Open

Slight incompatibility between LazyJSON.Object and JSON3.write #12

ninjaaron opened this issue Aug 7, 2019 · 2 comments

Comments

@ninjaaron
Copy link

ninjaaron commented Aug 7, 2019

Hi! Thanks for LazyJSON.jl.

julia> using LazyJSON, JSON3

julia> object = LazyJSON.value("""{"foo":"bar"}""")
LazyJSON.Object{Nothing,String} with 1 entry:
  "foo" => "bar"

julia> JSON3.write(object) |> println
{"\"foo\"":"bar"}

julia> JSON3.write(Dict("foo" => "bar")) |> println
{"foo":"bar"}

It's awesome that this even works at all, but as you can see, LazyJSON.Object keys somehow get extra quotes when printed. Since compatibility is already 99% there, it would be nice if this issue could be fixed. I don't know if the problem is on your end or JSON3's end, but I will open an issue over there as well (and I'll edit this post with a link to that issue when I get it posted).

Edit: link to the issue on JSON3.jl

@ninjaaron
Copy link
Author

@quinnj looked into it further (as can be seen on the other issue). It seems that the issue stems from the fact that the string(s::JSON.Value) returns the original substring directly from the source.

While I think this generally sensible, the convention in Julia is that subtypes of AbstractString don't return a repr (which is what I would say your version currently does). My recommendation would be for string(x::JSON.String) to return the Julia equivalent of the JSON string, to be more in line with the rest of the ecosystem. I'll try to get a PR together, though I have no idea what I'm getting into.

@ninjaaron
Copy link
Author

Uh, OK, what's the development workflow? I guess it's not the post 1.0 Pkg.jl one... I can't figure out how to run the tests.

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

1 participant