how to convert string with escape characters to json
I am looking for way to parse the below result as json object and get each attribute value
'{\'timestamp\':\'Thu, 05 Jul 2018 12:45:44 GMT\',\'type\':\'Unknown\',\'description\':\'{\\\'datetime\\\':\\\'2018-07-05T05:00:00.000Z\\\',\\\'description\\\':\\\'asddsf\\\',\\\'phoneNumbers\\\':\\\'456456456\\\',\\\'tools\\\':{\\\'skypeVideo\\\':true},\\\'rooms\\\':{\\\'GRB130\\\':true},\\\'additionalDetails\\\':\\\'this is test\\\'}\'}'
-
Hi Pavan,
You'd have to convert this string to a valid JSON format before you'll be able to parse this as JSON.
Might try something like the following. (assuming your string is the raw message. If you had first parsed this out you can replace _raw with whatever field name this string was initially parsed into)
| replace (_raw, "\\", "") as _raw //strip the backslashes
| replace (_raw, "'", "\"") as _raw //replace single quotes with double quotes
| replace (_raw, "\"{", "{") as _raw // remove quotes from before an open currly brace
| replace (_raw, "}\"", "}") as _raw //remove quotes from after a closing currly brace
| json auto
I hope that helps.
Please sign in to leave a comment.
Comments
1 comment