how to index a collection

Post Reply
grayghost4
Posts: 13
Joined: Wednesday 05th December 2018 5:00am

how to index a collection

Post by grayghost4 » Wednesday 05th December 2018 5:47am

I downloaded a file with json to a collection, now I need to index the collection to retrieve the data from the collection

listofdata = JSON.Decode(File.Load("~/airplane files/Conscendo S2.srm"))

myindex = "data" & "," & "autopilot" & "," & "altHoldRate"

Print listofdata.count ' this returns a number 9
Print listofdata.Length ' also returns a number 9

Print listofdata[myindex]

print count and length work and return a number, but the indexing does not work.
what am I doing wrong?

User avatar
cogier
Site Admin
Posts: 205
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: how to index a collection

Post by cogier » Wednesday 05th December 2018 3:55pm

Hi greyghost4 and welcome to the forum,

I cannot work out what you mean by needing to 'index' the data. I presume listofdata is a Collection.

I have attached a sample program that opens and displays a JSON file which may help. If not please can you post a copy of your JSON file and a little more detail of what you are aiming for.
JSON_Test.tar.gz
(12.93 KiB) Downloaded 5 times

grayghost4
Posts: 13
Joined: Wednesday 05th December 2018 5:00am

Re: how to index a collection

Post by grayghost4 » Friday 07th December 2018 7:34pm

I found the answer to my to the question :

need to use "[ ]" instead of " , " .... square brackets instead of a comma

Post Reply