I'm using views datasource to create JSON output of some nodes. They are of a custom content type that has two fields; title (text) and pg_topics (paragraph). Within the paragraph bundle are two text fields, subtitle and details.

The problems is that the pg_topics field is coming out as flat text, rather than a JSON array structure.

"node" : {
"title" : "Bathing and Grooming",
"field_pg_topics" : "\n \n Subtitle: How often should I bathe my puppy and what kind of shampoo is best?Details: Unless your puppy gets himself muddy or smelly for some reason..."}

I tried twiddling with the JSON settings, and created a custom display for the paragraph bundle, but can't get the output the way I want. Is it possible to create the paragraph output as a nested array?

Comments

pglatz created an issue.

codesmith’s picture

Did you have any luck with this or find a workaround?

mheinke’s picture

i need a Paragraphs json formatter in my life. output like this shouldnt exist:
"field_layer_set": "\n \n 0\n \n background\n \n 0\n \n 0\n \n, \n \n 1\n \n Middle Layer\n \n 30\n \n 30\n \n"

i might work on one in my spare time.

bneil’s picture

We have used Restful module very successfully to do nested JSON output, including Paragraph items. We have been moving away from views_datasource since it does not handle nested well for many/all resources.

arruk’s picture

This is three years old. Is there any movement on it?