0

This answer tells me that json starting with "[" is a list/array. Suffice to say, can several lists with dictionaries inside be considered valid json? As in [{"test": "test"}][{"test":"test"}] ?

I have some data returning that seems to be in this format but when I try and render the data inside a json viewer, it tells me it's the incorrect format. So maybe these viewers don't like json that's returned as a dictionary inside a list.

I'm not entirely sure if the data is in multiple lists but if I print "data[0] and then data1 then data[2] etc, it returns different dictionaries, so I assume it is a list. I would ideally like to loop through all the data so I could use a python for loop and say data[i] to go through all lists, but I suppose I would need to know what I am looping through.

Community
  • 1
  • 1
derpy
  • 67
  • 1
  • 6

1 Answers1

1

From your example [{"test": "test"}][{"test":"test"}] you actually have two different lists. And each list has a dictionary within it.

JSON parsers expect to parse one entity, so you need to put those two lists within a larger list. Like this:

[ [{"test": "test"}], [{"test":"test"}] ]
nivix zixer
  • 1,611
  • 1
  • 13
  • 19