1
我试图分析在我gradle这个任务的JSON文件。groovy.json.JsonSlurper解析JSON
CODE:
def jsonFile = "../files/json/myJSON.json"
def list = new JsonSlurper().parseText(jsonFile)
JSON - FILE
{
"prepare": {
"installed": [],
"uninstalled": []
},
"config": {
"files": []
}
}
但代码给了我以下异常:
Lexing failed on line: 1, column: 1, while reading '.', no possible valid JSON value or punctuation could be recognized.
而且我不明白为什么,我也验证在http://jsonlint.com/我的JSON-文件和它说,它是一个有效的JSON!
路径较长,但我不小心写错了。我现在更新了。 – Paul
无论路径如何,都是同样的问题。 –
现在有效。但是为了您的代码,我添加了.getText()。 丹科舍恩! – Paul