Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

update data in json using javascript

function setUsername(id, newUsername) {
  for (var i = 0; i < jsonObj.length; i++) {
    if (jsonObj[i].Id === id) {
      jsonObj[i].Username = newUsername;
      return;
    }
  }
}

// Call as
setUsername(3, "Thomas");
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #update #data #json #javascript
ADD COMMENT
Topic
Name
5+2 =