โ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())