
您正在寻找的是所谓的Jackson Streaming
API。这是使用Jackson流API的代码片段,可以帮助您实现所需的功能。
JsonFactory factory = new JsonFactory();JsonParser parser = factory.createJsonParser(new File(yourPathToFile));JsonToken token = parser.nextToken();if (token == null) { // return or throw exception}// the first token is supposed to be the start of array '['if (!JsonToken.START_ARRAY.equals(token)) { // return or throw exception}// iterate through the content of the arraywhile (true) { token = parser.nextToken(); if (!JsonToken.START_OBJECT.equals(token)) { break; } if (token == null) { break; } // parse your objects by means of parser.getXxxValue() and/or other parser's methods}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)