Extracting JSON Arrays from inside Json Objects

Sannyasin Brahmanathaswami brahma at hindu.org
Fri Jul 15 01:28:53 EDT 2016


given valid JSON like this:

in a var called "someJsonData"

{ 
    "file_id": "gr_1999-01-11_the-path-to-god",
	"file_size": null,
	"file_type": null,
	"format": null,
	"formats": [{
		"filename": "gr_1999-01-11_the-path-to-god.mp3",
		"format_name": "mp3",
		"isbn": null,
		"item_format_id": 1009,
		"item_id": 1217,
		"sale_date": null,
		"url": null
	}],
	"framesize": null,
	"genre": null
}

if we import this 

put JsonImport(someJsonData) into aLiveCodeArray

put the keys of tLiveCodeArray
returns what we expect,  file_id, file_size etc…

But then how does one address the elements in the JSON array "formats"?

aLiveCodeArray["formats"]["filename"]  would be my expectation; but that is empty

But I see from the dictionary that JSON arrays become lists, but documentation is too lean.

So, just to see what we are getting I tried this:

aLiveCodeArray["formats"} and still returns empty

OK so we can parse the JSON object, but how do we address elements in its internal arrays? 

BR
 



More information about the use-livecode mailing list