Answers for "how to add element in json object"

3

how to add element in json object

// base code ----------------------------------------------------------
	object["property"] = value;
	 // or
	object.property = value;
// exampel : ----------------------------------------------------------
	var myJson = { name: "mamad", family: "mirzaei" }
// i wana to add age 
	myJson.age = 26
// log =>
	console.log( "myJson >>:" ,myJson) 
// resalt =>
	{ name: "Mamad", family: "Mirzaei", age : 26 }
Posted by: Guest on June-15-2020
0

add to json object javascript

object.property = value;
Posted by: Guest on March-29-2020
0

add new element to existing json object

json = JSON.stringify(jsObj);
 console.log(json)
Posted by: Guest on January-01-2021

Code answers related to "how to add element in json object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language