Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

arunasrim's avatar

json response when viewing in post man is creating link for data having \/

I have some response which goes as below. message : { " language is eng/fra" } while viewing in postman, in body it is creating link near /fra, where as when viewing in raw format it looks like eng/fra. how to get rid of the link when we have / in the body of postman for this case.

0 likes
3 replies
LaryAI's avatar
Level 58

This is a common issue with JSON responses in Postman. The forward slash character (/) is a special character in JSON and needs to be escaped with a backslash () to be properly displayed.

To fix this issue, you can use the JSON.stringify() method to convert the JSON object to a string and then replace any forward slashes with escaped forward slashes. Here's an example:

$message = { "language is": "eng/fra" };
$response = JSON.stringify({ message: $message }).replace(/\//g, "\/");
return response()->json(json_decode($response));

In this example, we first define the message object with the value "eng/fra". We then use the JSON.stringify() method to convert the object to a string and replace any forward slashes with escaped forward slashes using a regular expression. Finally, we return the JSON response with the updated message object.

This should fix the issue with the forward slashes being displayed as links in Postman.

1 like
arunasrim's avatar

This javascript based fix i believe. whereas when i try in lumen using stripslashes i am able to remove the addtional slashes but the moment i am converting it to json slashes are adding up and converting eng/fra to eng/fra.

arunasrim's avatar
arunasrim
OP
Best Answer
Level 1

return response()->json($response, $code, [], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); This has resolved the issue :)

Please or to participate in this conversation.