sitemule / noxDB

Not only XML. SQL,JSON and XML made easy for IBM i
MIT License
41 stars 20 forks source link

Duplicate attribute in JSON output (utf8-branch only) #72

Open m1h43l opened 1 year ago

m1h43l commented 1 year ago

Using short attribute names in the node path expression leads to duplicate attribute nodes in the graph and in the JSON output.

dcl-proc main;
  dcl-s json pointer;
  dcl-s msg char(50);

  json = nox_newObject();
  nox_setStr(json : 'auth/type' : 'bearer');
  nox_setStr(json : 'auth/token' : 'token');
  msg = nox_asJsonText(json);
  dsply msg;
  nox_close(json);

  json = nox_newObject();
  nox_setStr(json : 'authorization/type' : 'bearer');
  nox_setStr(json : 'authorization/token' : 'token');
  msg = nox_asJsonText(json);
  dsply msg;
  nox_close(json);
end-proc;

Output:

DSPLY  {"auth":{"type":"bearer","token":"token"}}        
DSPLY  {"authorization":{"type":"bearer"},"authorization"

Note: The output is capped at 50 chars but we can see that the attribute authorization is outputted two times which is invalid JSON.