Return JSON Response Without Escaped Strings

Published Nov 05 2024

Are you trying to return something like a URL or file path in a json response and it looks like this?

http:\/\/example.com\/about

It's an easy fix:

return response()->json([
	'url' => $url
], 200, [], JSON_UNESCAPED_SLASHES);