spoon
2159
3
Laravel

Return pretty JSON data

Posted 3 years ago by spoon

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);
}

Please sign in or create an account to participate in this conversation.