pyjson5
pyjson5 copied to clipboard
pyjson5.Json5IllegalCharacter in list within dictionary, within list
Hi,
I've got an error when parsing a jsonc file, it seems to be a bug within the parser. Full error message is:
File "src/_legacy.pyx", line 53, in pyjson5.load
File "src/_exports.pyx", line 286, in pyjson5.decode_io
File "src/_decoder.pyx", line 913, in pyjson5._decode_callback
File "src/_decoder.pyx", line 815, in pyjson5._decode_all
pyjson5.Json5IllegalCharacter: ("Expected b'comma' or U+007d near 464, found U+0022", {'object': {'version': 'version', 'name': 'string', 'vertex': {'position': ['array', {'x': 'float32', 'y': 'float32', 'z': 'float32'}], 'indicies': ['array', 'optional', 'uint32'], 'normal': ['array', 'optional', {'i': 'float32', 'j': 'float32'}], 'color': ['array', 'optional', {'r': 'uint8', 'g': 'uint8', 'b': 'uint8'}]}}}, '"')
this issue happens when parsing this file:
{
"object":
{
"version":"version",
"name":"string",
// per vertex data
"vertex":
{
"position":["array", {"x":"float32", "y":"float32", "z":"float32"}],
"indicies":["array", "optional", "uint32"],
"normal":["array", "optional", {"i":"float32", "j":"float32"}],
"color":["array", "optional", {"r":"uint8", "g":"uint8", "b":"uint8"}],
"test":["array", "optional", {"test":["array", "uint8"]}]
},
// bundled data contains stuff links to jpegs, and other models
// for instance having a damage model or bounding boxes
"bundled_data":["array", "optional", "string"],
// any would contain everything you want,
// some custom info about the model, like wight and stuff
"metadata":["any", "optional"]
},
// contains info about how the file is supposed to look like
// type can be json, binary or text
// json can be defined only for the entire file
// binary and text can be selected for each parameter explicitly
"_decorator":
{
// type sets, these are decoration definitions per file, and represent an arbitrary name
// having multiple means you're expecting multiple different file types
"json":{
// json can't be modified as it simply dumps the file into a json
"_type":"json"
},
"ascii":{
// data in text files will be in human readable format
"_type":"text",
"_structure":[
{"name":"string", "sep":" "}, // separator is the character at the end
{"data":"", "sep":"\n"}
]
},
"bin":{
// data in binary will be in binary format
"_type":"binary",
"_hints":{
"position":[{"position":"uint64"}], // in file position, this can only be in bytes
"indicies":[{"position":"uint64"}],
"normal":[{"position":"uint64"}],
"color":[{"position":"uint64"}]
},
"_structure":[
// if the size is after data the data will always be 0
// since we need to know how big the data is before reading it
{"name":"string[32]"}, // [xxx] < means it's size limited
{"size":"uint64", "unit":"type"}, // units can be either type or bytes
{"data":""} // type should be same as data that were specifien
]
}
}
}
adding new line around text fixes this:
"test":["array", "optional", {
"test":["array", "uint8"]
}]
Hi! Thanks for filing a bug, but I think you've got the wrong json5 library. I think you want https://github.com/Kijewski/pyjson5 instead.
Closing this as it wasn't a bug in this library.