Getting stuff like this in my JSON responses:
\u003Cp\u003EOur Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\u003C/p\u003E\n
I'm assuming CakePHP 3.3 is doing something here. Using standard json and xml route extensions. With set and serialize in my controllers. Nothing out of the ordinary that I can think of. Any idea how to change this to something that can be easily decoded by a client or just turn off the encoding all together?
There's nothing strange about this, that's simply unicode tag representations of the opening and closing angled brackets of the HTML tags in your content. This conversion is being applied when using the JSON_HEX_TAG
option, which CakePHP does by default.
In fact, CakePHP currently uses
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT
by default. If you want to change this, use the _jsonOptions
view variable option to define your own bitmask, or set it to false
to disable the defaults, ie in your controller action do something like
$this->set('_jsonOptions', false);
See also