How do i split json object and update them according to the ID. I heard to use stringify! and how do i implement the function to update the object?
<input type="text" value="{"id":"1","price":"30.00","edit":0},
{"id":"2","price":"8.00","edit":0}" id="json" />
**code:**
var json = $('#json').val().split(',');
for (var i = 0; i < json.length; i++){
alert(json);
}
//(seems its splitting every comma it finds).
Im trying to archive:
hope my question clears enough :)
Instead of string split and parsing.. Try using $.parseJSON
like below,
$.parseJSON("[" + $('#json').val() + "]");
DEMO: http://jsfiddle.net/QUTu9/
Also fixed the quotes in html like below,
<input type="text" value='{"id":"1","price":"30.00","edit":0},
{"id":"2","price":"8.00","edit":0}' id="json" />