ajson
ajson copied to clipboard
Nodes containing `/`
I'm trying to parse https://raw.githubusercontent.com/abapedia/steampunk-2305-api/main/src/_status.json with AJSON.
{
"clas,/dmo/cx_rap_generator": {
"status": "RELEASED",
"successors": []
},
"clas,/iwbep/cl_cp_factory_remote": {
"status": "RELEASED",
"successors": []
},
"clas,/iwbep/cl_cp_factory_unit_tst": {
"status": "RELEASED",
"successors": []
},
There are no errors but the result is incorrect (the path column):
Clearly the / in the name confuses AJSON and should be escaped. Not sure how you want to approach a fix here.
Yeah ... that can ruin some internals ... especially UTs ...
- https://stackoverflow.com/questions/8676011/which-characters-are-valid-invalid-in-a-json-key-name
- https://www.json.org/json-en.html
The first link is a bit incorrect. Not all. All but the control chars. They must be escaped. Meaning that they will not present in a string. So the first idea is to use tab. But it will ruin all UTs and actually all existing addressing. Maybe in opposite, the / in the key should be replaced with tab ? Let's think about it for a while.
You are right, the / should be escaped in the original JSON. Maybe best to raise an error if the value contains unescaped special characters. But I guess it's still a problem if the value contains \/ (haven't tried).
That means unsupporting a valid JSON ... not ideal. I'm thinking on autoreplacing / with a tab for a path before search/set/etc ... but this is also a performance impact :(