2012-11-14 39 views
0

我想将一些JSON转换为PHP中的关联数组。由于某种原因,json_decode()的结果始终为NULL。json_decode不断返回null

我想我的JSON必须是畸形的,但我不知道为什么。什么是畸形的呢?

<?php 

$json = '{ markers:{ marker:[ { lat:50.30644, lng:18.03125, title:"Some name with accented characters ÅÄÖ", zoom:13, center:"false", street:"Dalahästvägen 56", zip:{ }, city:"117 58 MALMÖ", country:"SE", phone:"070-880 60 14", www:"domain.se/" }, { lat:59.5306, lng:18.08521, title:"ACME INC", zoom:13, center:"false", street:"ELFSBORGSVÄGEN 9", zip:{ }, city:"186 41 SIGTUNA", country:"SE", phone:"08-511 700 70", www:"acmegiantslingshots.se" }]}}' ; 

$arr = json_decode($json, true); 
print_r($arr); 

是因为某些对象属性没有价值吗?

+0

你的json无效请点击这里http://jsonlint.com/ – GBD

回答

4

必须使用"(双引号)引用所有字符串和键以符合JSON规范。

http://jsonlint.com通常是一个很好的工具,当你有东西打破了你的JSON解析器。

+0

+1更具体的答案在同一时间:) –