-
Notifications
You must be signed in to change notification settings - Fork 51
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
Bad handling of large amounts of fields #291
Comments
Hi stensmo, I ran into exactly this problem a couple of months back and have proposed a PR: #284 |
Try bumping to the latest version 1.14.1 and this behaviour should be fixed. |
Yes, this bug is solved now |
This however, still does not work: using JSON3 #= Put this content in the file test.json { =# #json_string = """{"objects":[{"a":1,"b":"here is a sting"},{"b":"here is a string with a quote -insert backslash here-"","a":1}]}""" !isfile("types.jl") && JSON3.writetypes(json_string, "types.jl"; module_name=:MyModule, root_name=:Root, mutable=false) !isdefined(Main, :MyModule) && include("types.jl") rootObject =JSON3.read(json_string, MyModule.Root) |
using JSON3
#=
Note that the fields d8 and d9 are swapped, which is OK according to the JSON specification. This example errors.
ERROR: LoadError: MethodError: Cannot
convert
an object of type String to an object of type Int64The function
convert
exists, but no method is defined for this combination of argument types.{
"objects": [
{
"a1": 1,
"a2": 2,
"a3": 3,
"a4": 4,
"a5": 5,
"a6": 6,
"a7": 7,
"a8": 8,
"a9": 9,
"b1": 11,
"b2": 12,
"b3": 13,
"b4": 14,
"b5": 15,
"b6": 16,
"b7": 17,
"b8": 18,
"b9": 19,
"c1": 21,
"c2": 22,
"c3": 23,
"c4": 24,
"c5": 25,
"c6": 26,
"c7": 27,
"c8": 28,
"c9": 29,
"d1": 31,
"d2": 32,
"d3": 33,
"d4": 34,
"d5": 35,
"d6": 36,
"d7": 37,
"d8": 38,
"d9": "39"
},
{
"a1": 1,
"a2": 2,
"a3": 3,
"a4": 4,
"a5": 5,
"a6": 6,
"a7": 7,
"a8": 8,
"a9": 9,
"b1": 11,
"b2": 12,
"b3": 13,
"b4": 14,
"b5": 15,
"b6": 16,
"b7": 17,
"b8": 18,
"b9": 19,
"c1": 21,
"c2": 22,
"c3": 23,
"c4": 24,
"c5": 25,
"c6": 26,
"c7": 27,
"c8": 28,
"c9": 29,
"d1": 31,
"d2": 32,
"d3": 33,
"d4": 34,
"d5": 35,
"d6": 36,
"d7": 37,
"d9": "39",
"d8": 38
}
]
}
=#
json_string="""{"objects":[{"a1":1,"a2":2,"a3":3,"a4":4,"a5":5,"a6":6,"a7":7,"a8":8,"a9":9,"b1":11,"b2":12,"b3":13,"b4":14,"b5":15,"b6":16,"b7":17,"b8":18,"b9":19,"c1":21,"c2":22,"c3":23,"c4":24,"c5":25,"c6":26,"c7":27,"c8":28,"c9":29,"d1":31,"d2":32,"d3":33,"d4":34,"d5":35,"d6":36,"d7":37,"d8":38,"d9":"39"},{"a1":1,"a2":2,"a3":3,"a4":4,"a5":5,"a6":6,"a7":7,"a8":8,"a9":9,"b1":11,"b2":12,"b3":13,"b4":14,"b5":15,"b6":16,"b7":17,"b8":18,"b9":19,"c1":21,"c2":22,"c3":23,"c4":24,"c5":25,"c6":26,"c7":27,"c8":28,"c9":29,"d1":31,"d2":32,"d3":33,"d4":34,"d5":35,"d6":36,"d7":37,"d9":"39","d8":38}]}"""
!isfile("types.jl") && JSON3.writetypes(json_string, "types.jl"; module_name=:MyModule, root_name=:Root, mutable=false)
!isdefined(Main, :MyModule) && include("types.jl")
rootObject =JSON3.read(json_string, MyModule.Root)
The text was updated successfully, but these errors were encountered: