1

I have a json string:

[{"file":"78jsyhpg9mtf.jpg"},{"file":"imqk2680ra4p.jpg"}]

that doesn't have primary object name. It is accessible via data(0)...

But how do I iterate with for next loop over all elements in collection?

Using

Set oJSON = New aspJSON for each file in oJSON.data() ... next

obviously doesn't work. And I can not use oJSON.data("name") as the collection does not have primary data object.

I am using this script: https://github.com/gerritvankuipers/aspjson/blob/master/aspJSON1.19.asp

Jerry2
  • 2,955
  • 5
  • 30
  • 39
  • `for each x in oJSON.data : Response.write oJSON.data(x).item("file") & "
    " : next`
    – Flakes May 05 '21 at 06:27
  • This actually works, I've tried everything else I guess... except this... Thank you so much. If you would write this in answer I will accept it. – Jerry2 May 05 '21 at 10:04
  • It's okay. Glad to help. – Flakes May 05 '21 at 10:35
  • Does this answer your question? [ASP JSON: Object not a collection](https://stackoverflow.com/questions/30538292/asp-json-object-not-a-collection) – user692942 May 07 '21 at 08:31

1 Answers1

2

You can loop through the nodes of the object like this

For Each obj in oJSON.data
  Response.Write( oJSON.data(obj).item("file") )
Next
luiscabus
  • 199
  • 3
  • 8