Closed soxofaan closed 11 months ago
interestingly, the json module from python stdlib does already support these JSON5 NaN
and Infinity
constructs properly:
>>> import json
>>> dump = '{"x": NaN, "y": Infinity, "z": -Infinity, "n": null}'
>>> for k, v in json.loads(dump).items():
... print(k, repr(v), type(v))
x nan <class 'float'>
y inf <class 'float'>
z -inf <class 'float'>
n None <class 'NoneType'>
so a good solution for full JSON5 support is not that urgent or blocking at the moment
There are also comments added into the mix and I'm not sure whether Python's default json supports that.
nope, no support for other JSON5 features like comments, unquoted keys, single quotes, trailing coma
It really only uses comments, all other features I'm trying not to use. If it's much simpler to implement I could also use a "$comment" property as in JSON schema.
Stripping commas before json parsing will also be pretty easy to do DIY-style (regex oneliner) without the need for full fledged JSON5 library.
You mean comments, not commas, right? But yes indeed. A simple regex should be able to cater for removing comments and then it could go into the native Python JSON module.
You mean comments, not commas, right?
Indeed.
but now that you mention it: DIY-stripping trailing comma's shouldn't be that hard either
Yes, but I'll try to ensure that we only need to strip comments and handle NaN/Infinity. Otherwise, I'll stick to pure JSON for now.
I felt like writing code around the json module was not worth it right now, I just used json-five for now.
the process examples to use in the "individual process testing" are written as JSON5: https://github.com/Open-EO/openeo-processes/tree/add-tests/tests
I already found a couple of options to read JSON5:
I have no idea yet on which one to bet at the moment