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