Answers for "js convert to json online"

41

js to json

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

js string to json

var obj = JSON.parse("{no:'u',my:'sql'}");//returnes {no:'u',my:'sql'}
Posted by: Guest on April-08-2020
0

Convert JSON String to JavaScript Object

<script>
  // Convert JSON String to JavaScript Object
  var JSONString = '[{"name":"Jonathan Suh","gender":"male"},{"name":"William Philbin","gender":"male"},{"name":"Allison McKinnery","gender":"female"}]';

  var JSONObject = JSON.parse(JSONString);
  console.log(JSONObject);      // Dump all data of the Object in the console
  alert(JSONObject[0]["name"]); // Access Object data
</script>
Posted by: Guest on June-08-2021
1

Javascript object convert into JSON

const person = {
    name: 'labib',
    age: 22,
    job: 'web-developer',
    frieds: ['ahsik', 'abir', 'alvi', 'hanafi'],
    childList: {
        firstChild: 'Salman',
        secondChild: 'Rafi',
        thirdChild: 'Anfi'
    }
}
const convertJson = JSON.stringify(person)
console.log(convertJson)
//Expected output:
/*
{"name":"labib","age":22,"job":"web-developer","frieds":["ahsik","abir","alvi","hanafi"],"childList":{"firstChild":"Salman","secondChild":"Rafi","thirdChild":"Anfi"}}
 */
Posted by: Guest on September-11-2021

Code answers related to "js convert to json online"

Code answers related to "Javascript"

Browse Popular Code Answers by Language