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/[email protected]
** 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