spoon's avatar

Return pretty JSON data

Hi,

Here's my JSON. I want to return "pretty" values, but even though I use unescaped_unicode, if there's a new line in the column, it echoes by adding a \n, which I don't want it to. If I echo the value using regular ->with(), I don't see any errors or \n text in the output.

How can I clean everything from the JSON value?

public function comments($id) {
    $book = Thing::find($id);
    return Response::json($book, 200, ['Content-type'=> 'application/json; charset=utf-8'], JSON_UNESCAPED_UNICODE);
}
0 likes
3 replies
RobinMalfait's avatar

What's the reason why you want to do that?

Compact json is less heavy for you requests and thus faster. If you need to pick it up with javascript, it will just be 'normal' without the \n but actually new lines...

:)

Please or to participate in this conversation.