sbcgua / ajson

Yet another json parser serializer for ABAP
MIT License
50 stars 15 forks source link

Nodes containing `/` #169

Open mbtools opened 1 year ago

mbtools commented 1 year ago

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.

sbcgua commented 1 year ago

Yeah ... that can ruin some internals ... especially UTs ...

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.

mbtools commented 1 year ago

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

sbcgua commented 1 year ago

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