0

Below is the result of my console.log(myJson)

[{"placeholdId":1,"itemId":null,"type":null},
{"placeholdId":2,"itemId":null,"type":null},
{"placeholdId":3,"itemId":null,"type":null},
{"placeholdId":4,"itemId":null,"type":null},
{"placeholdId":5,"itemId":5,"type":"food"},
{"placeholdId":6,"itemId":null,"type":"null"}]

how can I set the value of my object value base on the placeholdId? for example the 5th item, I want to change the itemId and type to null as well.

I'm stuck until here..

var obj = $.parseJSON(json);
console.log(obj[4]);
Jonathan Lonowski
  • 121,453
  • 34
  • 200
  • 199
James Lemon
  • 426
  • 5
  • 17
  • 2
    Try: `obj[4]['itemId'] = null;` Or if you don't know what order they're in then loop through the array checking for `obj[i]['placeholdId'] === 5`. – bloodyKnuckles Mar 30 '15 at 02:49
  • @bloodyKnuckles after checking what should I do? I want to change other values not the placeholdId – James Lemon Mar 30 '15 at 02:59

0 Answers0