Closed bcmartinez closed 4 years ago
Hello!
The JSONobject
class has a property that gives you access to the collection of JSON properties:
<%
Dim json, projects, project, template
Set json = New JSONobject
json.Parse(jsonString)
projects = json("projectTypes").pairs ' this is the list of name-value pairs that store the parsed JSON data properties
' you can iterate the pairs with regular for or for each loops
For Each project In projects
Response.Write project.name & ": " ' this is the key for the each child and will write "Project Template: " in that example
Set template = project.value ' this is the child JSONobject
Response.Write template("name") & " - " & template("ID") & "<br>" ' this will write "My Template Name - 123<br>"
Next
%>
@rcdmk - Thank you!
Hello! Is it possible to loop through properties and get property names? For example, here is the format of the json I'm dealing with (which comes from an API that I do not control):
I don't know any of the property names in advance, so I'd like to loop through them to display them on my page. Is it possible to do something like
objJson(0)
orobjJson(0).name
instead ofobjJson("projectTypes")
?