Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to update value in nested json using id in javascript

function getObjects(obj, key, val, newVal) {
  for (var i in obj) {
      if (!obj.hasOwnProperty(i)) continue;
      if (i == key && obj[key] == val) {
          obj[key] = newVal;
      }
  }
  return obj
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #update #nested #json #id #javascript
ADD COMMENT
Topic
Name
3+5 =