ajson icon indicating copy to clipboard operation
ajson copied to clipboard

Nodes containing `/`

Open mbtools opened this issue 2 years ago • 3 comments

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):

image

Clearly the / in the name confuses AJSON and should be escaped. Not sure how you want to approach a fix here.

mbtools avatar Aug 09 '23 17:08 mbtools

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.

sbcgua avatar Aug 09 '23 20:08 sbcgua

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).

mbtools avatar Aug 09 '23 20:08 mbtools

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 :(

sbcgua avatar Aug 10 '23 15:08 sbcgua