This is view settings for paragraph
format: Serializer, json
show: fields
content: paragraph
this is the result:
[{"field_paragra":" \u003Cdiv data-quickedit-entity-id=\u0022paragraph\/3\u0022 class=\u0022paragraph paragraph--type--parapgraph paragraph--view-mode--preview\u0022\u003E\n \n \u003Cdiv data-quickedit-field-id=\u0022paragraph\/3\/field_text\/en\/preview\u0022 class=\u0022field field--name-field-text field--type-string field--label-hidden field__item\u0022\u003Etest 1\u003C\/div\u003E\n \n \u003Cdiv data-quickedit-field-id=\u0022paragraph\/3\/field_tetdaasfsw\/en\/preview\u0022 class=\u0022field field--name-field-tetdaasfsw field--type-string field--label-hidden field__item\u0022\u003Etest 2\u003C\/div\u003E\n \n \u003C\/div\u003E\n, \u003Cdiv data-quickedit-entity-id=\u0022paragraph\/4\u0022 class=\u0022paragraph paragraph--type--parapgraph paragraph--view-mode--preview\u0022\u003E\n \n \u003Cdiv data-quickedit-field-id=\u0022paragraph\/4\/field_text\/en\/preview\u0022 class=\u0022field field--name-field-text field--type-string field--label-hidden field__item\u0022\u003Etest 3\u003C\/div\u003E\n \n \u003Cdiv data-quickedit-field-id=\u0022paragraph\/4\/field_tetdaasfsw\/en\/preview\u0022 class=\u0022field field--name-field-tetdaasfsw field--type-string field--label-hidden field__item\u0022\u003Etst 6\u003C\/div\u003E\n \n \u003C\/div\u003E\n, \u003Cdiv data-quickedit-entity-id=\u0022paragraph\/6\u0022 class=\u0022paragraph paragraph--type--parapgraph paragraph--view-mode--preview\u0022\u003E\n \n \u003Cdiv data-quickedit-field-id=\u0022paragraph\/6\/field_text\/en\/preview\u0022 class=\u0022field field--name-field-text field--type-string field--label-hidden field__item\u0022\u003Easdasa\u003C\/div\u003E\n \n \u003Cdiv data-quickedit-field-id=\u0022paragraph\/6\/field_tetdaasfsw\/en\/preview\u0022 class=\u0022field field--name-field-tetdaasfsw field--type-string field--label-hidden field__item\u0022\u003Ethis is a demo text\u003C\/div\u003E\n \n \u003C\/div\u003E\n"},{"field_paragra":""}]
Why it rendered as HTML instead of "neat" JSON ? Any setting I need to set?
Comments
Comment #2
apadernoComment #3
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedNot sure. Could you add more steps here on how to reproduce?
Comment #4
johnchqueWe need more steps to reproduce or more explanation about what you want to do. Till then, postponed.
Comment #5
pdhakal CreditAttribution: pdhakal as a volunteer commentedI also have the same problem. Whenever I create a new content type with nested fields like Paragraph, Field collection and then try to display in rest json through drupal 8 serializer/views. The result is similar. For an example the content type has following:
name (plain text)
addresses (field collection / paragraph, with unlimited values)
Street (plain text)
District (Plain text)
Now if we do a rest export in views with following details
FORMAT
Format: Serializer | Settings
Show :Fields | Settings
FIELDS
Content: name
Content: addresses (formatter: list)
We get the output like above. It is HTML not JSON. If we strip HTML, it will give strange string with lots of space \n characters, and values of street and district. If we put formatter = field collection Instead of field formatter = List then we get html as output.
Comment #6
mErilainen CreditAttribution: mErilainen at Wunder commentedHave you tried https://www.drupal.org/project/rest_views ?
Comment #7
imclean CreditAttribution: imclean commentedSee also REST Export Nested.
Comment #8
chrisjsimpson CreditAttribution: chrisjsimpson commentedThanks mErilainen #6 worked very well.
Written a step by step how to use it here: https://blog.karmacomputing.co.uk/drupal-8-rest-endpoint-with-entity-ref...
Thanks to cburschka for writing it!
Comment #9
fly2ganesh CreditAttribution: fly2ganesh as a volunteer commentedI am facing the same issue mentioned in comment #5 by @pdhakal. rest_views module isn't solving my issue. I will be looking for the solution.
Comment #10
mgoncalves CreditAttribution: mgoncalves as a volunteer commented#6 works.
Comment #11
Nestor_Fabian CreditAttribution: Nestor_Fabian as a volunteer commentedThanks with the rest_view module it worked for me.