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

alanyong created an issue. See original summary.

apaderno’s picture

Primsi’s picture

Not sure. Could you add more steps here on how to reproduce?

johnchque’s picture

Status: Active » Postponed (maintainer needs more info)

We need more steps to reproduce or more explanation about what you want to do. Till then, postponed.

pdhakal’s picture

I 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.

mErilainen’s picture

imclean’s picture

chrisjsimpson’s picture

Thanks 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!

fly2ganesh’s picture

I 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.

mgoncalves’s picture

#6 works.

Nestor_Fabian’s picture

Thanks with the rest_view module it worked for me.