解析键值jsonArray

final JsonReader reader =new JsonReader(new StringReader(videoCommentRowDataVO.getCommentJson()));

// 对于格式不好的json字符串, 需要设置此项

reader.setLenient(true);

final JsonArray original =new JsonParser().parse(reader).getAsJsonArray();

final Iterator iterator = original.iterator();

while (iterator.hasNext()) {

final JsonObject obj = iterator.next().getAsJsonObject();

if ( obj.get("type").getAsInt() ==TEXT_INTRO ) {

String commentVO=obj.get("content").toString();

commentRowDataVO.setComment(commentVO);

}

}

你可能感兴趣的:(解析键值jsonArray)