java - JSON: Expected value at 1:0 錯誤
問題描述
在看別人寫的源碼里面有一個錯誤,JSON: Expected value at 1:0 錯誤
這是啥意思啊?
該文件內容
/* 前后端通信相關的配置,注釋只允許使用多行方式 */{ /* 上傳圖片配置項 */ 'imageActionName': 'uploadimage', /* 執行上傳圖片的action名稱 */ 'imageFieldName': 'upfile', /* 提交的圖片表單名稱 */ 'imageMaxSize': 2048000, /* 上傳大小限制,單位B */ 'imageAllowFiles': ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], /* 上傳圖片格式顯示 */ 'imageCompressEnable': true, /* 是否壓縮圖片,默認是true */ 'imageCompressBorder': 1600, /* 圖片壓縮最長邊限制 */ 'imageInsertAlign': 'none', /* 插入的圖片浮動方式 */ 'imageUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'imagePathFormat': '/images/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 *//* {filename} 會替換成原文件名,配置這項需要注意中文亂碼問題 *//* {rand:6} 會替換成隨機數,后面的數字是隨機數的位數 *//* {time} 會替換成時間戳 *//* {yyyy} 會替換成四位年份 *//* {yy} 會替換成兩位年份 *//* {mm} 會替換成兩位月份 *//* {dd} 會替換成兩位日期 *//* {hh} 會替換成兩位小時 *//* {ii} 會替換成兩位分鐘 *//* {ss} 會替換成兩位秒 *//* 非法字符 : * ? ' < > | *//* 具請體看線上文檔: fex.baidu.com/ueditor/#use-format_upload_filename */ /* 涂鴉圖片上傳配置項 */ 'scrawlActionName': 'uploadscrawl', /* 執行上傳涂鴉的action名稱 */ 'scrawlFieldName': 'upfile', /* 提交的圖片表單名稱 */ 'scrawlPathFormat': '/images/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'scrawlMaxSize': 2048000, /* 上傳大小限制,單位B */ 'scrawlUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'scrawlInsertAlign': 'none', /* 截圖工具上傳 */ 'snapscreenActionName': 'uploadimage', /* 執行上傳截圖的action名稱 */ 'snapscreenPathFormat': '/images/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'snapscreenUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'snapscreenInsertAlign': 'none', /* 插入的圖片浮動方式 */ /* 抓取遠程圖片配置 */ 'catcherLocalDomain': ['127.0.0.1', 'localhost', 'img.baidu.com'], 'catcherActionName': 'catchimage', /* 執行抓取遠程圖片的action名稱 */ 'catcherFieldName': 'source', /* 提交的圖片列表表單名稱 */ 'catcherPathFormat': '/images/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'catcherUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'catcherMaxSize': 2048000, /* 上傳大小限制,單位B */ 'catcherAllowFiles': ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], /* 抓取圖片格式顯示 */ /* 上傳視頻配置 */ 'videoActionName': 'uploadvideo', /* 執行上傳視頻的action名稱 */ 'videoFieldName': 'upfile', /* 提交的視頻表單名稱 */ 'videoPathFormat': '/images/upload/ueditor/video/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'videoUrlPrefix': '', /* 視頻訪問路徑前綴 */ 'videoMaxSize': 102400000, /* 上傳大小限制,單位B,默認100MB */ 'videoAllowFiles': ['.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg','.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid'], /* 上傳視頻格式顯示 */ /* 上傳文件配置 */ 'fileActionName': 'uploadfile', /* controller里,執行上傳視頻的action名稱 */ 'fileFieldName': 'upfile', /* 提交的文件表單名稱 */ 'filePathFormat': '/images/upload/ueditor/file/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'fileUrlPrefix': '', /* 文件訪問路徑前綴 */ 'fileMaxSize': 51200000, /* 上傳大小限制,單位B,默認50MB */ 'fileAllowFiles': ['.png', '.jpg', '.jpeg', '.gif', '.bmp','.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg','.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid','.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso','.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml' ], /* 上傳文件格式顯示 */ /* 列出指定目錄下的圖片 */ 'imageManagerActionName': 'listimage', /* 執行圖片管理的action名稱 */ 'imageManagerListPath': '/images/upload/ueditor/image/', /* 指定要列出圖片的目錄 */ 'imageManagerListSize': 20, /* 每次列出文件數量 */ 'imageManagerUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'imageManagerInsertAlign': 'none', /* 插入的圖片浮動方式 */ 'imageManagerAllowFiles': ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], /* 列出的文件類型 */ /* 列出指定目錄下的文件 */ 'fileManagerActionName': 'listfile', /* 執行文件管理的action名稱 */ 'fileManagerListPath': '/images/upload/ueditor/file/', /* 指定要列出文件的目錄 */ 'fileManagerUrlPrefix': '', /* 文件訪問路徑前綴 */ 'fileManagerListSize': 20, /* 每次列出文件數量 */ 'fileManagerAllowFiles': ['.png', '.jpg', '.jpeg', '.gif', '.bmp','.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg','.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid','.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso','.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml' ] /* 列出的文件類型 */}
問題解答
回答1:似乎是格式不對,你可以去http://www.json.cn/試試
回答2:你這個是jeecg嗎,你那邊后來解決好了嗎
回答3:我也遇到了相同的問題,
應該是文件的編碼格式問題,我把文件的編碼格式從 'UTF-8格式編碼' 改為 'UTF-8無BOM格式編碼',就好了
json格式已經驗證過沒有問題,所以就懷疑是字符編碼問題
回答4:JSON語法中好像不支持添加注釋,而且還是故意如此設置的,不過把這段JSON放到JS中應該就不會有這樣的報錯。
I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn’t.
Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser.?
以上摘自知乎問答:https://www.zhihu.com/questio...
我這邊用Eclipse的JSON Editor查看預覽也是一對報錯,報錯標記部分都是注釋內容
相關文章:
1. mysql優化 - mysql count(id)查詢速度如何優化?2. angular.js - 不適用其他構建工具,怎么搭建angular1項目3. mysql主從 - 請教下mysql 主動-被動模式的雙主配置 和 主從配置在應用上有什么區別?4. python - django 里自定義的 login 方法,如何使用 login_required()5. 主從備份 - 跪求mysql 高可用主從方案6. java8中,邏輯與 & 符號用在接口類上代表什么意思7. python如何不改動文件的情況下修改文件的 修改日期8. angular.js - angular-ui-bootstrap 報錯無法使用?9. node.js - node_moduls太多了10. python - 關于ACK標志位的TCP端口掃描的疑惑?
