how to convert string with escape characters to json

Comments

1 comment

  • Avatar
    Kevin

    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. 

    0
    Comment actions Permalink

Please sign in to leave a comment.