jquery - How to get values of JSON object to string using javascript -
i have json object. example:
{ "id": 1, "name": "name", "surname": "surname", "number": "111111111" }
how make string json object using javascript, looks this.
name surname 111111111
you can use for...in
statement iterating values of object. in loop add every value string.
var json = { "id": 1, "name": "name", "surname": "surname", "number": "111111111" }; var str = ""; (var key in json) { str += (key != "id") ? (json[key] + " ") : ""; } console.log(str);
Comments
Post a Comment