我有一个简单的杰克逊解析器,它应该返回我的值,但我只得到null
值。任何想法将不胜感激?
示例 Json 数据:
{"a":"ab","b":"cd","c":"cd","d":"de","e":"ef","f":"fg"}
代码:
var jfactory = new JsonFactory()
var jParser : JsonParser = jfactory.createJsonParser(new File(outputDir + "/" + "myDic.json"))
while (jParser.nextToken() != JsonToken.END_OBJECT) {
var k = jParser.getCurrentName();
jParser.nextToken();
var v = jParser.getText();
println(k +"---" + v)
phoneDict.put(k,v);
i = i + 1;
println(phoneDict.size)
var t = readLine("Dict Done ?")
}
输出:
null---null
1
Dict Done ?
null---null
1
Dict Done ?
null---null
1
Dict Done ?
null---null
1
Dict Done ?