-4
    var x=[{"name":"james","age":"23"},{"name":"job","age":"55"}];

How to convert array of json object to below response

   {{"name":"james","age":"23"},{"name":"job","age":"55"}};
Nicolas
  • 7,819
  • 3
  • 20
  • 47
lalli
  • 7
  • 2

1 Answers1

1

  let x=[{"name":"james","age":"23"},{"name":"job","age":"55"}];
  console.log(JSON.stringify(x));

The desired output isnt proper JSON. To convert any javascript object into a json string simply use the function JSON.stringify(obj). JSON.parse(string) can be used to create an object out of a string.

Aaron
  • 1,420
  • 1
  • 7
  • 14