Thanks Tracy - I'll take a look

-----Original Message-----
From: ProfoxTech <[email protected]> On Behalf Of Tracy Pearson
Sent: 12 February 2019 15:22
To: [email protected]
Subject: RE: Parsing a JSON object

Sent by an external sender
------------------------------

Hi Paul,

This might be what you are looking for:
https://www.example-code.com/foxpro/json_paths.asp

I think the outside one you'll need to know. But there might be a way to deal 
with it.

Each time I've used the JsonObject, I've known the structure I was expecting. 
So doing something generic wasn't needed. I just needed to step through layers 
and these made it easier.

HTH,
Tracy

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Paul Newton
Sent: Tuesday, February 12, 2019 9:49 AM
To: [email protected]
Subject: Parsing a JSON object

Hi all

I am investigating the use of Chilkat's tools for parsing JSON objects but I am 
having trouble developing a generic routine.  For example, take the
following:

Local loJsonObject As 'Chilkat_9_5_0.JsonObject'
Local lcStrJsonObject, lnNumPets
lcStrJsonObject =
'{"pets":[{"name":"jack","breed":"terrier"},{"name":"john","breed":"bulldog"
},{"name":"joe","breed":"terrier"}]}'
loJsonObject = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonObject.Load(lcStrJsonObject)
i = 0
lnNumPets = loJsonObject.SizeOfArray("pets") DO WHILE i < lnNumPets
                loJsonObject.I = i
    ? STR(i) + ": " + loJsonObject.StringOf("pets[i].name") + "," +
loJsonObject.StringOf("pets[i].breed")
    i = i + 1
ENDDO

What I am trying to do is make the code generic such that I do not need to 
refer to "pets", "name" and "breed".  Any help would be much appreciated.  I 
have found a generic method for parsing JSON arrays but so far have been unable 
to do so for JSON objects

Paul Newton

[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/mn2pr02mb59207be6e3606553f70bff9da1...@mn2pr02mb5920.namprd02.prod.outlook.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to