Answers for "js object that is a string to java object"

PHP
3

how convert object to string and string to object in javascript

// convert to string
JSON.stringify(myObject)

// convert to object
JSON.parse(myObject)
Posted by: Guest on October-09-2021
17

string to object

const json = '{ "fruit": "pineapple", "fingers": 10 }';
const obj = JSON.parse(json);
console.log(obj.fruit, obj.fingers);
Posted by: Guest on May-20-2020

Browse Popular Code Answers by Language