Hi,
I am having trouble parsing some JSON received, everything I have tried so far has failed.
I have JSON like this:
{
“templateList”:[
{
“templateKey”:380,
“templateName”:“TestHTMLForm”,
“templateType”:“HTML”
},
{
“templateKey”:383,
“templateName”:“TestHTML2”,
“templateType”:“HTML”
},
{
“templateKey”:407,
“templateName”:“TestPDF”,
“templateType”:“PDF”
}
],
“listElementCount”:3,
“resultCode”:0,
“resultMessage”:""
}
In my app I have created a class for the templates with properties matching the values in the JSON. I wanted to create an array of the templates that I could then display. But I haven’t been able to parse the JSON array. The variable I create for the JSON item that is the templateList, which is an array of JSON objects, always disappears (in the debugger) when I try to work with the template list item.
I create the JSON object with: ResultJSON = new JSONItem(jsonString) <-- this works, I see my JSON in the debugger
If ResultJSON.HasName("templateList") Then
Dim JMTemplates As JSONItem = ResultJSON.Value("templateList") <-- this fails, variable "JMTemplates" just disappears in the debugger
End if
I tried creating an array of JSONItem, but didn’t get it right to assign the array. I thought I need to create a JSON item that is an array, then step through each item in the array to extract each JSON item value.
The example JSON app hasn’t helped me and other questions and answers I have found haven’t help yet. Any ideas on how I can parse this?
Thanks,
Peter