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:
- Split the object {“id”:”1″,”price”:”30.00″,”edit”:0}, {“id”:”2″,”price”:”8.00″,”edit”:0}
- Update depends on selected ID.
- and then save and it return same object format but with updated value.
hope my question clears enough 🙂
Instead of string split and parsing.. Try using
$.parseJSONlike below,DEMO: http://jsfiddle.net/QUTu9/
Also fixed the quotes in html like below,