How to convert strings that look like JSON to JSON objects

Greetings All,

I am running into a problem where my JSON objects cease being JSON objects and become strings when I do set variable and get variable in order to have them in scope in the final (top) path where I am building my final JSON payload which causes formatting issues (See the red lines):

I thought I might be able to simply string everything into one long path to keep it simple, but one of the routers is really necessary as the ‘trip’ can have no stops, one stop or five stops AND I cannot figure a way to access the data from another path without doing set and get.

Any general pointers with respect to how to restore this:

{\n\t"lat": 40.68987,\n\t"lon": -74.17821,\n\t"city": null,\n\t"time": "2024-11-11T20:00:00.000Z",\n\t"state": null,\n\t"address": "JFK",\n\t"country": "US",\n\t"zipCode": null,\n\t"address1": null,\n\t"landmark": "JFK Airport",\n\t"flightInfo": {\n\t\t"airlineCode": "EK",\n\t\t"flightNumber": "412"\n\t},\n\t"stopNumber": 0,\n\t"locationType": "airport",\n\t"specialInstructions": "Test Pickup Instructions"\n}

TO:

{ "lat": 40.68987, "lon": -74.17821, "city": null, "time": "2024-11-11T20:00:00.000Z", "state": null, "address": "JFK", "country": "US", "zipCode": null, "address1": null, "landmark": "JFK Airport", "flightInfo": { "airlineCode": "EK", "flightNumber": "412" }, "stopNumber": 0, "locationType": "airport", "specialInstructions": "Test Pickup Instructions" }

…will definitely be appreciated.

I was hoping that there was a magic module that would allow me to simply combine all the paths back together (See the green lines).

Thanks All,

Paul

Hello @Paul_Murray,
Try this
{{replace(Your JSON string with that \n and \t or directly add variable; "/(\\n|\\t)/g"; emptystring)}}

Your JSON string contains \n and \t, so it must be removed before giving it to ParseJSON. Use replace the function with a regular expression and remove extra \n and \t from your string.


:bulb:P.S.: Always search first, Check Make Academy. If this is helpful, mark it as a solution :white_check_mark: and :+1:
Need expert help or have questions? Contact or comment below! :point_down:

1 Like

Thank you, so much @dilipborad !!

I am on the road, but I will try this as soon as I get back on Friday.

Thanks again!

Paul

1 Like