JSON.stringify()

Total Post:113

Points:791
JSON 
 92  View(s)
Ratings:
Rate this:

What is JSON.stringify().

  1. Post:140

    Points:984
    Re: JSON.stringify()

    JSON.stringify() :

    Exchange data from a web server in JSON is common use. When we sending data to a web server,the data has to be a string. Convert a JS object into a string with JSON.stringify(). 

    Stringify a JavaScript Object: 

    var obj = { "name":"Prakash", "age":19, "city":"Allahabad"};
    
    var myJSON = JSON.stringify(obj);

    Example:

    var obj = { "name":"Prakash", "age":19, "city":"Allahabad"};
    
    var myJSON = JSON.stringify(obj);
    document.getElementById("Mindstick").innerHTML = myJSON;


    Stringify a JavaScript Array :

    var arr = [ "Prakash", "Nidhi", "Verma", "mindstick" ]; 
    var myJSON = JSON.stringify(arr);

    Ex: 

    var arr = [ "Prakash", "Nidhi", "Verma", "mindstick" ];
    
    var myJSON = JSON.stringify(arr);
    document.getElementById("Mindstick").innerHTML = myJSON;

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!