Question

I am generating the json from PHP.

Was it helpful?

Solution

The correct way is to use json_encode()

OTHER TIPS

The JSON is just a subset of Javascript, so everything you know about escaping strings in Javascript applies to JSON.

And yes, the correct answer is to use one of library functions, there is a quite a few of them around: see A completely fair and balanced comparison of php json libraries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top