javascript - array and object confusion in json -


what different between is

var json = [{ 'id':1, 'name':'john' }] 

and

var json = { 'id':1, 'name':'john' } 

my understanding in code 1 json array, means can have multiple object contains property of id , name. second 1 it's object. it?

and how one

var json = ['id':1,'name':'john'] 

compare code one?

nothing valid json in case.

the first 1 array of native javascript objects.

the second 1 javascript object.

the last 1 isn't valid , throw error. syntactically wrong.

use json.stringify() on javascript arrays or objects make valid json.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -