【发布时间】:2012-05-24 17:47:41
【问题描述】:
所以我有以下 PHP 字符串:
$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":"He'll 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"}
我需要的是:“印第安人官方推特报道称,周一,阿卡尔多从哥伦布被召来。” “他将在本赛季开始时在快船队出场 13 次以 2.76 的 ERA 取代丹·惠勒。”作为子串。但我似乎无法找出最好和最优雅的方式来做到这一点。我尝试对字符串进行 JSON_decode,但没有返回任何内容。有任何想法吗? (我正在使用 PHP)
【问题讨论】:
-
你能给我们一个你用来解析它的代码的sn-p吗?另外,请注意 json_decode 有第二个变量,可让您选择它是数组还是对象。
-
@sfgiants2010 您的 json 数据包含许多未转义的单引号,我已修复它,请检查我的答案。