I have a content type with embedded Paragraphs, and I'm trying to get those paragraphs into a JSON response, via a Views endpoint, along with the rest of the node. For example:
- Product (content type)
- Name (field)
- Price (field)
- Details (Paragraphs)
- Description (WYSIWYG field)
- Features (WYSIWYG field)
- A dozen other random paragraphs (Paragraphs)
Getting the name and price fields out of JSON is easy. I've also learned that I'm able to get ALL the paragraphs concatenated into one giant string by using the "multiple rows" option in Views, but the problem is that each Product can have a dozen or more such paragraphs, most of which are useless for this API endpoint. Doing it that way results in one gigantic string that often fails parsing because of unpredictably embedded unicode (newer emoji, etc.) that aren't encoded correctly, no matter how I set the options.
I don't really care about most of those paragraphs. I just want to get the "Details" paragraphs and its fields in the response, but I can't seem to find a way to limit it that way. Adding "Details" as a relationship results in duplicate entries per product, I think because the WYSIWYG field is used in other paragraph types too. Most of the duplicates are blank. Making the "Details" relationship required then erroneously filters out all the products with no details, which is not what I want either.
Sorry, I've spent hours researching this, and maybe I'm just not using the right search terms...?
All I really want is one product per JSON entry, with a nested Details paragraph in the product, but not all the other extra paragraphs. Am I missing something obvious or is there really no easy way to filter by paragraph type in a View?