java - JSON: Expected value at 1:0 錯(cuò)誤
問題描述
在看別人寫的源碼里面有一個(gè)錯(cuò)誤,JSON: Expected value at 1:0 錯(cuò)誤
這是啥意思啊?
該文件內(nèi)容
/* 前后端通信相關(guān)的配置,注釋只允許使用多行方式 */{ /* 上傳圖片配置項(xiàng) */ 'imageActionName': 'uploadimage', /* 執(zhí)行上傳圖片的action名稱 */ 'imageFieldName': 'upfile', /* 提交的圖片表單名稱 */ 'imageMaxSize': 2048000, /* 上傳大小限制,單位B */ 'imageAllowFiles': ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], /* 上傳圖片格式顯示 */ 'imageCompressEnable': true, /* 是否壓縮圖片,默認(rèn)是true */ 'imageCompressBorder': 1600, /* 圖片壓縮最長邊限制 */ 'imageInsertAlign': 'none', /* 插入的圖片浮動(dòng)方式 */ 'imageUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'imagePathFormat': '/images/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 *//* {filename} 會(huì)替換成原文件名,配置這項(xiàng)需要注意中文亂碼問題 *//* {rand:6} 會(huì)替換成隨機(jī)數(shù),后面的數(shù)字是隨機(jī)數(shù)的位數(shù) *//* {time} 會(huì)替換成時(shí)間戳 *//* {yyyy} 會(huì)替換成四位年份 *//* {yy} 會(huì)替換成兩位年份 *//* {mm} 會(huì)替換成兩位月份 *//* {dd} 會(huì)替換成兩位日期 *//* {hh} 會(huì)替換成兩位小時(shí) *//* {ii} 會(huì)替換成兩位分鐘 *//* {ss} 會(huì)替換成兩位秒 *//* 非法字符 : * ? ' < > | *//* 具請?bào)w看線上文檔: fex.baidu.com/ueditor/#use-format_upload_filename */ /* 涂鴉圖片上傳配置項(xiàng) */ 'scrawlActionName': 'uploadscrawl', /* 執(zhí)行上傳涂鴉的action名稱 */ 'scrawlFieldName': 'upfile', /* 提交的圖片表單名稱 */ 'scrawlPathFormat': '/images/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'scrawlMaxSize': 2048000, /* 上傳大小限制,單位B */ 'scrawlUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'scrawlInsertAlign': 'none', /* 截圖工具上傳 */ 'snapscreenActionName': 'uploadimage', /* 執(zhí)行上傳截圖的action名稱 */ 'snapscreenPathFormat': '/images/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'snapscreenUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'snapscreenInsertAlign': 'none', /* 插入的圖片浮動(dòng)方式 */ /* 抓取遠(yuǎn)程圖片配置 */ 'catcherLocalDomain': ['127.0.0.1', 'localhost', 'img.baidu.com'], 'catcherActionName': 'catchimage', /* 執(zhí)行抓取遠(yuǎn)程圖片的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', /* 執(zhí)行上傳視頻的action名稱 */ 'videoFieldName': 'upfile', /* 提交的視頻表單名稱 */ 'videoPathFormat': '/images/upload/ueditor/video/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'videoUrlPrefix': '', /* 視頻訪問路徑前綴 */ 'videoMaxSize': 102400000, /* 上傳大小限制,單位B,默認(rèn)100MB */ 'videoAllowFiles': ['.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg','.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid'], /* 上傳視頻格式顯示 */ /* 上傳文件配置 */ 'fileActionName': 'uploadfile', /* controller里,執(zhí)行上傳視頻的action名稱 */ 'fileFieldName': 'upfile', /* 提交的文件表單名稱 */ 'filePathFormat': '/images/upload/ueditor/file/{yyyy}{mm}{dd}/{time}{rand:6}', /* 上傳保存路徑,可以自定義保存路徑和文件名格式 */ 'fileUrlPrefix': '', /* 文件訪問路徑前綴 */ 'fileMaxSize': 51200000, /* 上傳大小限制,單位B,默認(rèn)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', /* 執(zhí)行圖片管理的action名稱 */ 'imageManagerListPath': '/images/upload/ueditor/image/', /* 指定要列出圖片的目錄 */ 'imageManagerListSize': 20, /* 每次列出文件數(shù)量 */ 'imageManagerUrlPrefix': '', /* 圖片訪問路徑前綴 */ 'imageManagerInsertAlign': 'none', /* 插入的圖片浮動(dòng)方式 */ 'imageManagerAllowFiles': ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], /* 列出的文件類型 */ /* 列出指定目錄下的文件 */ 'fileManagerActionName': 'listfile', /* 執(zhí)行文件管理的action名稱 */ 'fileManagerListPath': '/images/upload/ueditor/file/', /* 指定要列出文件的目錄 */ 'fileManagerUrlPrefix': '', /* 文件訪問路徑前綴 */ 'fileManagerListSize': 20, /* 每次列出文件數(shù)量 */ '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:你這個(gè)是jeecg嗎,你那邊后來解決好了嗎
回答3:我也遇到了相同的問題,
應(yīng)該是文件的編碼格式問題,我把文件的編碼格式從 'UTF-8格式編碼' 改為 'UTF-8無BOM格式編碼',就好了
json格式已經(jīng)驗(yàn)證過沒有問題,所以就懷疑是字符編碼問題
回答4:JSON語法中好像不支持添加注釋,而且還是故意如此設(shè)置的,不過把這段JSON放到JS中應(yīng)該就不會(huì)有這樣的報(bào)錯(cuò)。
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查看預(yù)覽也是一對報(bào)錯(cuò),報(bào)錯(cuò)標(biāo)記部分都是注釋內(nèi)容
相關(guān)文章:
1. python - 爬蟲模擬登錄后,爬取csdn后臺(tái)文章列表遇到的問題2. javascript - 求幫助 , ATOM不顯示界面!!!!3. javascript - angular使從elastichearch中取出的文本高亮顯示,如圖所示4. 視頻文件不能播放,怎么辦?5. python bottle跑起來以后,定時(shí)執(zhí)行的任務(wù)為什么每次都重復(fù)(多)執(zhí)行一次?6. mysql - 分庫分表、分區(qū)、讀寫分離 這些都是用在什么場景下 ,會(huì)帶來哪些效率或者其他方面的好處7. javascript - ios返回不執(zhí)行js怎么解決?8. javascript - 移動(dòng)端自適應(yīng)9. html5 - HTML代碼中的文字亂碼是怎么回事?10. mysql 查詢身份證號(hào)字段值有效的數(shù)據(jù)
