Reputation: 13972
I am generating the json from PHP.
Upvotes: 3
Views: 18245
Reputation: 647
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.
Upvotes: 2