且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP复杂字符串解析,可以使用JSON吗?

更新时间:2023-01-15 16:39:03

您有几个未转义的字符串,这导致了错误.一种简单的格式可以节省您的时间.

you have few unescaped string, that is causing the error. a simple formatting could have saved you the time.

$output = '{
    "playerId":1178,
    "percentChange":0.1,
    "averageDraftPosition":260,
    "percentOwned":0.1,
    "mostRecentNews": {
        "news":"Accardo was called up from Columbus on Monday, the Indians official Twitter feed reports",
        "spin":"Hell replace Dan Wheeler on the active roster after carrying a 2.76 ERA over 13 appearances with the Clippers to start the season.",
        "date":"Mon May 14"
    },
    "fullName":"Jeremy Accardo"
}';
$json = json_decode($output);