JmsSerializer escapes new line (\n instead of n)

I’m using symfony 4 alongside FOSRestBundle and JMSSerializer.
What I’m encountering is when object data transformed into json by JMSSerializer during preparing view object into response, backslash is being added before newline characters(n) stored in object string fields.

So part of my response data looking like this:

"hint": "10% с объема заказов комьюнити на 1 уровнеn5% с объема заказов комьюнити на 2-4 уровне"

And what I want is to preserve object’s string field original content:

"hint": "10% с объема заказов комьюнити на 1 уровнеn5% с объема заказов комьюнити на 2-4 уровне"

JMSSerializer is configured following way:

    visitors:
        json:
            options:
                - JSON_UNESCAPED_UNICODE
                - JSON_PRETTY_PRINT

I tried using with no luck:

- JSON_UNESCAPED_SLASHES

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *