Answers for "json serialize javascript"

10

node json stringify

let data = {
  name: "John Smith",
  age: 30,
  hobbies: ["Programming", "Video Games"]
};

// {name:"John Smith",age:30,hobbies:["Programming","Video Games"]}
let miny = JSON.stringify(data);

// The 4 parameter signifys 4 spaces. You can also use "\t".
/* {
 *     name: "John Smith",
 *     age: 30,
 *     ...
 */
let pretty = JSON.stringify(data, null, 4);
Posted by: Guest on June-20-2020
41

object to json javascript

var person={"first_name":"Tony","last_name":"Hawk","age":31};
var personJSONString=JSON.stringify(person);
Posted by: Guest on July-23-2019
0

json.stringify file object return {}

// get File Object  
var fileObject = getFile();

// reCreate new Object and set File Data into it
var newObject  = {
   'lastModified'     : fileObject.lastModified,
   'lastModifiedDate' : fileObject.lastModifiedDate,
   'name'             : fileObject.name,
   'size'             : fileObject.size,
   'type'             : fileObject.type
};  

// then use JSON.stringify on new object
JSON.stringify(newObject);
Posted by: Guest on July-20-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language