cancel
Showing results for 
Search instead for 
Did you mean: 

Turning Embedded JSON into Data

pcoleman
New Contributor III

Hi…I have a REST get that returns the following as part of it’s payload:
image

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?

10 REPLIES 10

bojanvelevski
Valued Contributor

Hey @pcoleman,

Can you send a sample of the response? Even
a small chunk would be enough.

image
Here’s an image of the response. It’s basically JSON embedded in an xml.

j_angelevski
Contributor III

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.

Unfortunately, it gives me the following when I try that. It seems to somehow interpret it as a list.
“error”:
“Expecting a string argument”

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