Re: [fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Graeme Geldenhuys
On 2017-02-08 16:47, Michael Van Canneyt wrote:
> Indeed. If you experiment in the browser console:


It might just be worth adding a small note about that "gotcha" in the
FindPath documentation.


Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Michael Van Canneyt



On Wed, 8 Feb 2017, Graeme Geldenhuys wrote:


On 2017-02-08 16:33, Michael Van Canneyt wrote:

One way is to allow to escape dots in the path.
But because every character is allowed in a javascript object property, that
would mean that \. can also be a correct property name, and so we need to
introduce \\ as an escape for \...

It could be added.



No, I think that will just get messy (your choice). I was just wondering
if I was doing something wrong. Either way, I managed to use TJSONenum
and it worked just fine for my needs.


Indeed. If you experiment in the browser console:

var obj = {};
undefined
obj
Object {  }
obj["1.2.3"] = 'ok';
"ok"
obj
Object { 1.2.3: "ok" }
obj['allez"na'] = 'ok';
"ok"
obj
Object { 1.2.3: "ok", allez"na: "ok" }
obj['not\nice']="beeeh"
"beeeh"
obj
Object { 1.2.3: "ok", allez"na: "ok", not
ice: "beeeh" }
obj['not\ nice']="beeeh"
"beeeh"
obj
Object { 1.2.3: "ok", allez"na: "ok", not
ice: "beeeh", not nice: "beeeh" }

Not so nice at all...

Michael.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Graeme Geldenhuys
On 2017-02-08 16:33, Michael Van Canneyt wrote:
> One way is to allow to escape dots in the path. 
> But because every character is allowed in a javascript object property, that
> would mean that \. can also be a correct property name, and so we need to
> introduce \\ as an escape for \...
> 
> It could be added.


No, I think that will just get messy (your choice). I was just wondering
if I was doing something wrong. Either way, I managed to use TJSONenum
and it worked just fine for my needs.


Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TJSONData.FindPath() troubles where data contains dots.

2017-02-08 Thread Michael Van Canneyt



On Wed, 8 Feb 2017, Graeme Geldenhuys wrote:


Hi,

I've studied the following documenation to make sure I'm using
FindPath() correctly.


http://www.freepascal.org/docs-html/3.0.0/fcl/fpjson/tjsondata.findpath.html


since . is used as a delimiter between path segments, you indeed cannot find 
paths
that contain a . in a segment.

I see no nice way out of this.

One way is to allow to escape dots in the path. 
But because every character is allowed in a javascript object property, that

would mean that \. can also be a correct property name, and so we need to
introduce \\ as an escape for \...

It could be added.

Michael
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal