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
Post a Comment