retrohacker retrohacker - 7 months ago 11
JSON Question

Storing Array in JSON

I am working on a research project that requires storing a large amount of external data. I have settled on the JSON format, which I have never used, as a storage format. All I really need to store is a large array of data however every example of JSON I can find that has an array in it is nested inside of an object. for example:

{ "NumberList" : {
"array" : [ 1, 2, 3, 4, 5, 6] }}

Is it possible to have only an array? Such as:

"array" : [1,2,3,4,5,6]

Without an opening and closing bracket or a surrounding object?


No, that is the way the JSON is formatted

The opening/closing { } are saying this is in json (I guess kind of like <html></html>)

There is no reason you can't do

{ "array" : [1,2,3,4,5,6] }

What this is saying is that there is one field called array which contains an array of numbers