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