Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

json javascript

// Storing data:
myObj = {name: "John", age: 31, city: "New York"};
myJSON = JSON.stringify(myObj);
localStorage.setItem("testJSON", myJSON);

// Retrieving data:
text = localStorage.getItem("testJSON");
obj = JSON.parse(text);
document.getElementById("demo").innerHTML = obj.name;
Comment

JASON in javascript

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Json Tutorial</title>
</head>
<body>
    <div class="container">This is my container</div>
    <script>
        let jsonObj = {
            name: "Harry",
            channel: "CWH",
            friend: "Rohan Das",
            food: "Bhindi" //#bhindiLoverSquad
        } 
        console.log(jsonObj);
        let myJsonStr = JSON.stringify(jsonObj);
        console.log(myJsonStr);

        myJsonStr = myJsonStr.replace('Harry', 'Larry');
        console.log(myJsonStr)

        newJsonObj = JSON.parse(myJsonStr);
        console.log(newJsonObj)

        


    </script>
</body>
</html>
Comment

json javascript

var obj = {name: 'John', age: 20}

// to json
var json = JSON.stringify(obj);

//json to object
var obj1 = JSON.parse(json);
Comment

JavaScript and JSON

// JSON syntax
{
    "name": "John",
    "age": 22,
    "gender": "male",

}
Comment

JavaScript JSON

{
"employees":[
  {"firstName":"John", "lastName":"Doe"},
  {"firstName":"Anna", "lastName":"Smith"},
  {"firstName":"Peter", "lastName":"Jones"}
]
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: faker.js name 
Javascript :: js clone deep 
Javascript :: jquery on ready 
Javascript :: javascript find and replace text in html 
Javascript :: javascript onclick open url same window 
Javascript :: how to submit form using ajax 
Javascript :: mongodb findOneAndUpdate return updated 
Javascript :: toggle button by javascript 
Javascript :: how to get innerhtml value in javascript 
Javascript :: ionic 3 alert 
Javascript :: how to run curl in javascript 
Javascript :: javascript append item to array 
Javascript :: regular expression javascript password strength 
Javascript :: update file json trong javascript 
Javascript :: javascript check less width of window 
Javascript :: regex to indentify url 
Javascript :: how to align text vertically center beside an image in react native 
Javascript :: error: expected undefined to be a graphql schema. 
Javascript :: axios send post data 
Javascript :: inline confirm box javascript 
Javascript :: rect p5js 
Javascript :: ajax load document ready 
Javascript :: vue js reload page 
Javascript :: js querySelectorAll map sample 
Javascript :: how to make proptypes either or 
Javascript :: javascript cahnge colour of strokerect 
Javascript :: put 0 in front of month number javascript 
Javascript :: how to get selected value of dynamically created dropdown in jquery 
Javascript :: innerhtml replace javascript 
Javascript :: Find smallest Number from array in javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =