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 add a class in classlist and remove after 100 ms using jquery 
Javascript :: primeng browseranimationsmodule 
Javascript :: datatable sAjaxSource get output 
Javascript :: save data response from fetch as global param js 
Javascript :: node redirect 
Javascript :: getx oninit 
Javascript :: cloudflare worker read url params 
Javascript :: this.jsObject.functions is not a function 
Javascript :: ease between 2 points 
Javascript :: use params in Class based component 
Javascript :: javascript delete object from array 
Javascript :: react router v6 pass props 
Javascript :: canvas draw rect dashed 
Javascript :: how to use aos 
Javascript :: str_limit function filter vuejs 
Javascript :: how to add debounce in react redux js 
Javascript :: Delete a Cookie with JavaScript 
Javascript :: shopify guest login 
Javascript :: arduino vscode hex 
Javascript :: react convert table to pdf 
Javascript :: override backswipe behaviour in ios and android react native 
Javascript :: opposite number js 
Javascript :: does kendo window content clear on close 
Javascript :: javascript switch syntax 
Javascript :: remove all chars from string and leave only numbers javascript and leav space betwin numbers 
Javascript :: convert string to integer javascript 
Javascript :: Material-ui aircon icon 
Javascript :: javascript make title blink 
Javascript :: formdata is empty after append in angular 
Javascript :: ionic vue use .env 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =