我正在尝试在我的 gradle 任务中解析 JSON 文件。
CODE:
def jsonFile = "../files/json/myJSON.json"
def list = new JsonSlurper().parseText(jsonFile)
JSON-文件
{
"prepare": {
"installed": [],
"uninstalled": []
},
"config": {
"files": []
}
}
但代码给了我以下异常:
Lexing failed on line: 1, column: 1, while reading '.', no possible valid JSON value or punctuation could be recognized.
我不明白为什么,我还验证了我的 JSON 文件http://jsonlint.com/它说它是一个有效的 JSON!
上面的代码试图解析字符串../files/json/myJSON.json
作为 JSON。而是使用:
def jsonFile = new File("../files/json/myJSON.json")
def map = new JsonSlurper().parse(jsonFile)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)