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 :: how to change textContent in js 
Javascript :: template strings in js 
Javascript :: knex insert multiple rows 
Javascript :: if array includes string 
Javascript :: index.js:1 You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors. 
Javascript :: arrow function example 
Javascript :: javascript difference between window and Window 
Javascript :: how to make a bigint in javascript 
Javascript :: What is cookies, sessionStorage, localStorage. 
Javascript :: slide js 
Javascript :: pass array as argument javascript 
Javascript :: gettimezoneoffset javascript 
Javascript :: js keycodes 
Javascript :: javascript best online game engine 
Javascript :: function 
Javascript :: events jquery 
Javascript :: lodash template literal 
Javascript :: typescript base64 from file 
Javascript :: make indexOF in js 
Javascript :: Check Whether Variable Is String Or Number In JavaScript 
Javascript :: how to display a calender in react native 
Javascript :: react native image slider 
Javascript :: python json loads single quotes 
Javascript :: nodejs vs python 
Javascript :: req.body 
Javascript :: lettre au hasard javascript 
Javascript :: react lifecycle hooks 
Javascript :: how to declare 3d array in javascript 
Javascript :: use of slot in vue 
Javascript :: react datetime mannual editing 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =