我将这个JSON对象存储在纯文本文件中:{ "MySQL": { "Server": "(server)", "Username": "(user)", "Password": "(pwd)", "DatabaseName": "(dbname)" }, "Ftp": { "Server": "(server)", "Username": "(user)", "Password": "(pwd)", "RootFolder": "(rf)" }, "BasePath": "../../bin/", "NotesAppPath": "notas", "SearchAppPath": "buscar", "BaseUrl": "http:\/\/montemaiztusitio.com.ar", "InitialExtensions": [ "nem.mysqlhandler", "nem.string", "nem.colour", "nem.filesystem", "nem.rss", "nem.date", "nem.template", "nem.media", "nem.measuring", "nem.weather", "nem.currency" ], "MediaPath": "media", "MediaGalleriesTable": "journal_media_galleries", "MediaTable": "journal_media", "Journal": { "AllowedAdFileFormats": [ "flv:1", "jpg:2", "gif:3", "png:4", "swf:5" ], "AdColumnId": "3", "RSSLinkFormat": "%DOMAIN%\/notas\/%YEAR%-%MONTH%-%DAY%\/%TITLE%/", "FrontendLayout": "Flat", "AdPath": "ad", "SiteTitle": "Monte Maíz: Tu Sitio", "GlobalSiteDescription": "Periódico local de Monte Maíz.", "MoreInfoAt": "Más información aquí, en el Periódico local de Monte Maíz.", "TemplatePath": "templates", "WeatherSource": "accuweather:SAM|AR|AR005|MONTE MAIZ", "WeatherMeasureType": "1", "CurrencySource": "cotizacion-monedas:Dolar|Euro|Real", "TimesSingular": "vez", "TimesPlural": "veces" }}当我尝试用解码时json_decode(),它返回NULL。为什么?该文件是可读的(我尝试了回显file_get_contents(),但工作正常)。我已经针对http://jsonlint.com/测试了JSON ,它是完全有效的。怎么了解在Google上寻找答案,我回到SO:调用webservice后json_decode返回NULL。我的JSON文件具有UTF BOM序列(一些不应包含的二进制字符),因此破坏了JSON结构。进入十六进制编辑器,删除了字节。一切恢复正常。为什么会这样呢?因为我使用Microsoft Windows的记事本编辑了文件。好主意!
- 3 回答
- 0 关注
- 1039 浏览
添加回答
举报
0/150
提交
取消