處理顯然有效的JSON 的json_decode() 的NULL 輸出
PHP 的json_decode() 函數偶爾會回傳NULL,即使是看似有效的JSON輸入。當使用第三方工具驗證 JSON 時,這個問題可能會特別令人困惑。
考慮以下 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",
以上是儘管有有效的 JSON 輸入,為什麼 json_decode() 會回傳 NULL?的詳細內容。更多資訊請關注PHP中文網其他相關文章!