1

I'm new to Drupal and I've very excited about the possibly of headless as it will align with my current skillset and let me be productive more quicly while I continue to learn Drupal. (I come from a full stack .NET background using consuming REST services on the frontend).

I'm having some trouble with the JSON format.

I've set up a REST Export view in Drupal 8.3 that returns a custom content type. It includes a three fields: title, body(plain text), and an image.

The result that I get has a lot of escape characters and I'm not sure how to get it to just return the plain text data.

Here is the result that I get:

[{"title":"A test for the json api","field_body":"This is a test. It\u0026#039;s pretty awesome and I love you.","field_test_image":"\/drupal\/sites\/default\/files\/2017-04\/Adam_Dickison_1.png"}]

What I'd like to get back is this:

[{"title":"A test for the json api","field_body":"This is a test. It's pretty awesome and I love you.","field_test_image":"/drupal/sites/default/files/2017-04/Adam_Dickinson_1.png"}]

I've checked my php.ini and magic_quotes_gpc is set to 'Off'.

Can anybody help me figure this out. I didn't see any general settings. I've changed all of the field settings to remove html and to give me just the plain text.

Thanks in advance.

0

Looks like I need to decode the unicode string on the client side.

0

On your view page, click on the 'Field settings'. i.e.

Format:

Show: Fields | Settings

Click on the 'Settings'. You will see a popup window. And select the 'RAW OUTPUT' for the respective field. Also, you can provide ALIAS for the field.

I guess you were looking for this option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.