javascript - JSON encoding by browser -


i sending below json response:

{     "employees": [         { "firstname":"john" , "lastname":"doe" }, // response json         { "firstname":"peter" , "lastname":"jones" }     ] } 

but browsers interpreting above json

{ "firstname":"john" , "lastname":"doe" },   // interpreted json { "firstname":"peter" , "lastname":"jones" } 

it trailing out wrapped object of json.

i thought because default, first tag read. however,that can still loop through records, since still in array format.

to prevent this, should include tag, example:

{    "data":{       "employees":[          {             "firstname":"john",             "lastname":"doe"          },          {             "firstname":"peter",             "lastname":"jones"          }       ]    } } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -