-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
  • 8,077
  • 4
  • 21
  • 51
lalli
  • 17
  • 3

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,600
  • 1
  • 8
  • 14