02-25-2022 11:10 AM
Hi…I have a REST get that returns the following as part of it’s payload:
Not sure what the right approach is, but I ultimately want to take that JSON that comes back as text in that $ field and turn it into documents. Not sure if I should be looking at the map() function or what. Any thoughts?
02-25-2022 01:01 PM
Hey @pcoleman,
Can you send a sample of the response? Even
a small chunk would be enough.
02-28-2022 07:59 AM
Here’s an image of the response. It’s basically JSON embedded in an xml.
02-28-2022 06:57 AM
Hi @pcoleman,
The following expression
JSON.parse(jsonPath($, "entity.feed.entry[*].content['$']"))
should be enough to parse the JSON string, you don’t need to replace the \n
characters.
02-28-2022 07:53 AM
Unfortunately, it gives me the following when I try that. It seems to somehow interpret it as a list.
“error”:
“Expecting a string argument”
02-28-2022 08:16 AM
Most likely the JSON.parse() method recieved an array instead of string.
If your content it’s always on the same index in your entry array, you can use the following expression
JSON.parse($entity.feed.entry[2].content['$'])
or
JSON.parse(jsonPath($, "entity.feed.entry[*].content['$']").toString())