ZF-7157: Zend_Json should support JavaScript comments

Issue Type: Improvement Created: 2009-06-29T11:05:58.000+0000 Last Updated: 2009-06-29T13:32:10.000+0000 Status: Resolved Fix version(s): Reporter: Larry Root (lroot) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Json

Related issues: Attachments:


Currently if you try and decode a JSON value that contains a comment like:

<pre class="literal">
// comment
{"foo": "bar"}

The result is a single string property (zend_debug::dump):

<pre class="literal">
string '// comment
{"foo": "bar"}' (length=25)

It would be nice if Zend_Json were able to identify and strip the "//" and /* */" based comments prior to decoding so that JSON strings with comments would parse as expected.


Posted by Matthew Weier O'Phinney (matthew) on 2009-06-29T13:09:02.000+0000

I need a little input before working on this. First, is ext/json enabled in your PHP installation? Second, how are you decoding JSON values -- via Zend_Json::decode()? or are you going straight to Zend_Json_Decoder?

I ask the questions as I'm trying to determine if the problem exists in Zend_Json, or upstream in ext/json.

Posted by Larry Root (lroot) on 2009-06-29T13:22:03.000+0000

Im using Zend_Json::decode() and leveraging the Json module (1.2.1). Im using PHP 5.2.6 and ZF 1.8.3

Posted by Matthew Weier O'Phinney (matthew) on 2009-06-29T13:31:38.000+0000

Zend_Json::decode() defaults to using ext/json when enabled -- which means your issue is upstream. Please report it at

Posted by Matthew Weier O'Phinney (matthew) on 2009-06-29T13:32:10.000+0000

Closing as "Won't Fix" as the issue is upstream.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.