What is the correct way to avoid text in JSON responses?

I am generating json from PHP.

+3
source share
2 answers

The correct way is to use json_encode ()

+19
source

JSON is just a subset of Javascript, so all you know about escaping strings in Javascript is JSON.

And yes, the correct answer is to use one of the library functions, there are quite a lot of them: see Completely fair and balanced comparison of php json libraries .

+2
source

Source: https://habr.com/ru/post/1698958/


All Articles