sitemule / noxDB

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

Node with space in the middle of the key is not located #54

Open m1h43l opened 3 years ago

m1h43l commented 3 years ago

Node with the key "city charter" is not located with jx_locate(json : 'city charter').

Unit test NOXDBUT3 test case TEST_KEY_WITH_SPACE.

wimjongman commented 1 year ago

We run into this as well:

**free
Ctl-Opt BndDir('NOXDB') dftactgrp(*NO) ACTGRP('QILE' );

/include qrpgleref,JSONPARSER

dcl-s p2 pointer;
dcl-s txt varchar(50);

// fail
p2 = json_parseString('{"valid key": "test"}');
txt = json_getValue(p2:'valid key');
dsply txt;
json_delete(p2);

// success
p2 = json_parseString('{"validkey": "test"}');
txt = json_getValue(p2:'validkey');
dsply txt;
json_delete(p2);

*inlr = *on;      
NielsLiisberg commented 1 year ago

A workaround is to change the blank delimiter to something else by json_setDelimiter() .. But is is on our list so you can escape any char this ways with double quotres:

txt = json_getValue(p2:'"valid key"');

and more obvious:

txt = json_getValue(p2:'/root/"valid key"/"funny array name"[123]."another name with blanks"');

On Thu, May 11, 2023 at 10:41 AM Wim Jongman @.***> wrote:

We run into this as well:

*free Ctl-Opt BndDir('NOXDB') dftactgrp(NO) ACTGRP('QILE' );

/include qrpgleref,JSONPARSER

dcl-s p2 pointer; dcl-s txt varchar(50);

// fail p2 = json_parseString('{"valid key": "test"}'); txt = json_getValue(p2:'valid key'); dsply txt; json_delete(p2);

// success p2 = json_parseString('{"validkey": "test"}'); txt = json_getValue(p2:'validkey'); dsply txt; json_delete(p2);

inlr = on;

— Reply to this email directly, view it on GitHub https://github.com/sitemule/noxDB/issues/54#issuecomment-1543584472, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVIPHX2BCNB4BA23QM7Z4TXFSQ4DANCNFSM5EGQBEUA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

wimjongman commented 1 year ago

That does not work, unfortunately. Or I did not understand your instructions:

**free
Ctl-Opt BndDir('NOXDB') dftactgrp(*NO) ACTGRP('QILE' );

/include qrpgleref,JSONPARSER

dcl-s p2 pointer;
dcl-s txt varchar(50);

// fail
p2 = json_parseString('{"valid key": "test"}');
txt = json_getValue(p2:'"valid key"');
dsply txt;
json_delete(p2);

// success
p2 = json_parseString('{"validkey": "test"}');
txt = json_getValue(p2:'"validkey"');
dsply txt;
json_delete(p2);

*inlr = *on;    
NielsLiisberg commented 1 year ago

Sorry , i was not clear;

Look at this sample:

https://github.com/sitemule/noxDB/blob/master/examples/JSONPARS2E.JSON-Parse-String-names-with-dots.rpgle

Basically you can change all delimiters in noxDb - also the blank:

The default is:

/// // Default delimiters for JSON and XML data strings. /// Dcl-C JX_DELIMITERS const('/\@[] .{}''"$');

So you can replace the blank in the path to be vertical line json_setDelimiters(''/\@[]|.{}''"$'););

.. not easy to see but I changed the sixth character from blank to a vertical line;

On Thu, May 11, 2023 at 12:48 PM Wim Jongman @.***> wrote:

That does not work, unfortunately. Or I did not understand your instructions:

*free Ctl-Opt BndDir('NOXDB') dftactgrp(NO) ACTGRP('QILE' );

/include qrpgleref,JSONPARSER

dcl-s p2 pointer; dcl-s txt varchar(50);

// fail p2 = json_parseString('{"valid key": "test"}'); txt = json_getValue(p2:'"valid key"'); dsply txt; json_delete(p2);

// success p2 = json_parseString('{"validkey": "test"}'); txt = json_getValue(p2:'"validkey"'); dsply txt; json_delete(p2);

inlr = on;

— Reply to this email directly, view it on GitHub https://github.com/sitemule/noxDB/issues/54#issuecomment-1543767574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVIPHTPO7YYHBZH2ASOUSDXFS7YPANCNFSM5EGQBEUA . You are receiving this because you commented.Message ID: @.***>