json_decode() returns null issues

前端 未结 10 2170
误落风尘
误落风尘 2020-12-03 11:47

I\'ve an issue with my JSON. It works returns correctly in PHP 5.3 (so I can\'t use json_last_error()), and it returns successfully when I copy string explicitly into json_d

10条回答
  •  误落风尘
    2020-12-03 12:20

    When I use:

    phpunit --log-json file.json 
    

    (using PHPUnit 3.4.13), The file that it creates does not appear to contain valid JSON,

    the json file contains "json" which looks something like:

    {...}{...}{...}{...}
    

    Instead of what I would expect to see:

    [{...},{...},{...},{...}]
    

    Not sure if the is the same problem that you're seeing, your sample JSON output in the question appears to be more valid that what I'm seeing.

    Once adding the missing commas and brackets, it can be parsed with json_decode() on PHP 5.2.10 or PHP 5.3.2.

提交回复
热议问题