I have been trying to read in a large JSON file and am not getting very far…
Part of the text file is:
{“General”:{“Code”:“GSPC”,“Type”:“INDEX”,“Name”:“S&P 500”,“Exchange”:“INDX”,“CurrencyCode”:“USD”,“CurrencyName”:“US Dollar”,“CurrencySymbol”:“$”,“CountryName”:“USA”,“CountryISO”:“US”},“Components”:{“0”:{“Code”:“AIZ”,“Exchange”:“US”,“Name”:“Assurant Inc”,“Sector”:“Financial Services”,“Industry”:“Insurance-Specialty”},“1”:{“Code”:“MNST”,“Exchange”:“US”,“Name”:“Monster Beverage Corp”,“Sector”:“Consumer Defensive”,“Industry”:“Beverages-Non-Alcoholic”},“2”:{“Code”:“MTCH”,“Exchange”:“US”,“Name”:“Match Group Inc”,“Sector”:“Communication Services”,“Industry”:“Internet Content & Information”}
I need to extract the Code of each company… I have tried (using parts of the examples) the following lines:
Dim SpJsonFIle as FolderItem = GetFolderItem(“/home/gary/SpiderOakHive/buylist_rb/sptics.json”)
Dim SPTickers as New Xojo.IO.FolderItem(“/home/gary/SpiderOakHive/buylist_rb/sptics.json”)
Dim TIS as Xojo.IO.TextInputStream
Dim SPText as Text
Dim res as Xojo.core.Dictionary
Try
TIS=Xojo.IO.TextInputStream.Open(SPTickers, Xojo.core.TextEncoding.UTF8)
SPText=TIS.ReadAll
Catch err
'MessageBox(err)
Return
End Try
Try
res=Xojo.Data.ParseJSON(SPText)
Catch Err
'MessageBox(Err)
Return
End Try
Var TickerArray() as Variant
Var CompTick() as String
For Each d as Dictionary in TickerArray
CompTick = d.Value(“Code”)
Next
And I am able to read in the data…but am unable to determine how to drill down to the parts I need. I have screen shot a few of the variables in the IDE, links to the shots:
portman.no-ip.biz/first_level.png
portman.no-ip.biz/second_level.png
portman.no-ip.biz/third_level.png
portman.no-ip.biz/fourth_level.png
portman.no-ip.biz/fifth_level.png
Source file for the json file: portman.no-ip.biz/sptics.json