5 years ago

Clean way to return existing JSON string?

Posted 5 years ago by ATOM-Group

Many times I get data from file_get_contents(), which returns a JSON serialized string. I can't just do return Response::json(...) because it then re-encodes the string.

I want want to have to run json_decode() first, only to re-encode it with headers, but I also don't want to manually do:

header('Content-Type: application/json)
echo $data;

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