Edit report at http://bugs.php.net/bug.php?id=52502&edit=1

 ID:                 52502
 Updated by:         [email protected]
 Reported by:        zelnaga at gmail dot com
 Summary:            json_decode doesn't always work
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            *General Issues
 Operating System:   Windows 7
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

PHP uses the reference implementation from json.org.  json.org states
that a new-

line in json is written as \n and not a literal newline.  If you can
convince 

Douglas Crockford at json.org that this should be valid json, we will
fix it.  

Otherwise, no chance.


Previous Comments:
------------------------------------------------------------------------
[2010-07-31 04:50:11] zelnaga at gmail dot com

Description:
------------
In particular, "{\"test\": [\"\n\"]}" doesn't give the correct result. 
Examples follow.

Test script:
---------------
<?php

$a = "{\"test\": [\"\n\"]}";



echo "$a\r\n";



var_dump(json_decode($a, true));

?>

Expected result:
----------------
I would expect an array to be output.  ie.



array(1) {

  ["test"]=>

  array(1) {

    [0]=>

    string(1) "

"

  }

}



Certainly javascript has no problem with it:



<script
src="http://github.com/kvz/phpjs/raw/master/functions/strings/echo.js";></script>

<script
src="http://github.com/kvz/phpjs/raw/master/functions/var/var_dump.js";></script>

<script>

a = {"test": ["\n"]};



var_dump(a);

</script>

Actual result:
--------------
NULL


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52502&edit=1

Reply via email to