Homerclese Member Licensed User Longtime User Jul 27, 2016 #1 I have some JSON that I need to parse, which looks like this: Code: Copy [ { "Id":1, "Name":"ABC" }, { "Id":2, "Name":"XYZ" } ] Because the top level isn't an object, I am parsing it and converting it to a List like this: Code: Copy Dim JSON As JSONParser JSON.Initialize(Job.GetString) Dim JSONList As List = JSON.NextArray That works. But then I want to convert each element in the list into a Map. I know I can use a For/Next loop to loop through the list but is there a more elegant want to do this using a For/Each loop, e.g.: Code: Copy For Each JSONMap As ??? In JSONList Next If so, what is the type of entity?
I have some JSON that I need to parse, which looks like this: Code: Copy [ { "Id":1, "Name":"ABC" }, { "Id":2, "Name":"XYZ" } ] Because the top level isn't an object, I am parsing it and converting it to a List like this: Code: Copy Dim JSON As JSONParser JSON.Initialize(Job.GetString) Dim JSONList As List = JSON.NextArray That works. But then I want to convert each element in the list into a Map. I know I can use a For/Next loop to loop through the list but is there a more elegant want to do this using a For/Each loop, e.g.: Code: Copy For Each JSONMap As ??? In JSONList Next If so, what is the type of entity?
DonManfred Expert Licensed User Longtime User Jul 27, 2016 #2 Code: Copy Dim parser As JSONParser parser.Initialize(<text>) Dim root As List = parser.NextArray For Each colroot As Map In root Dim Id As Int = colroot.Get("Id") Dim Name As String = colroot.Get("Name") Next See http://basic4ppc.com:51042/json/index.html Upvote 0
Code: Copy Dim parser As JSONParser parser.Initialize(<text>) Dim root As List = parser.NextArray For Each colroot As Map In root Dim Id As Int = colroot.Get("Id") Dim Name As String = colroot.Get("Name") Next See http://basic4ppc.com:51042/json/index.html
Homerclese Member Licensed User Longtime User Jul 27, 2016 #3 D'oh! So obvious. Thank you sir. Upvote 0