Based on my understanding of this subject, I’ve come up with the following function for translating a string from PHP to JSON, strictly conforming to the RFC4627.
{[ .json_string | 1.hilite(=php,ln-1=) ]}
A simple test like this
{[ .test | 1.hilite(=php,ln-1=) ]}
yields (in comparison to the _encodeString method of the Zend_Json_Encoder class of Zend Framework)