-3

I'm fetching some string from backend in the following format, how to parse it into JSON.

"{messages:"[{message_type:S,message_text:Instance 20000001002700000279 of object type RentalObjectREFX has been changed.}{message_type:S,message_text:Email sent sucessfully}]"}"
guradio
  • 15,524
  • 4
  • 36
  • 57
adirocks27
  • 141
  • 1
  • 6
  • 15
  • 2
    use JSON.parse() – RJParikh Jun 28 '17 at 08:47
  • 1
    don't confuse your head too much, there are no such thing as JSON objects. JSON is text. Always. A codification for data. And i guess we wouldn't see these kind of questions if ppl read manuals, or just type a search on a web engine.. – Kaddath Jun 28 '17 at 08:50
  • Does this answer your question? [Safely turning a JSON string into an object](https://stackoverflow.com/questions/45015/safely-turning-a-json-string-into-an-object) – Boghyon Hoffmann Jul 12 '21 at 16:20

1 Answers1

0

Like that

var json = JSON.parse('{"messages":"[{message_type:S,message_text:Instance 20000001002700000279 of object type RentalObjectREFX has been changed.}{message_type:S,message_text:Email sent sucessfully}]"}');

console.log(json);
Yordan Nikolov
  • 2,598
  • 13
  • 16