我正在使用gson来解析json 我有一个com.google.gson.jsonArray
JsonObject object = jelement2.getAsJsonObject().getAsJsonObject("fields");
JsonArray jArray = (JsonArray) object.get("entity_facets");
Output of jArray is :
[{"count":4,"entity":"Com","Company":[{"sector":"Communications","ticker":"VZ","entity":"Verizon","type":"BCap","instance":[{"count":1,"entity":"Verizon (VZ, Fortune 500)"}]},{"sector":"Technology","ticker":"AAPL","entity":"Apple","type":"BCap","instance":[{"count":1,"entity":"Apple (AAPL, Fortune 500)"}]},{"sector":"Communications","ticker":"T","entity":"AT&T","type":"BCap","instance":[{"count":1,"entity":"(T, Fortune 500)"},{"count":1,"entity":"AT&T"}]}]}]
现在我想从jArray
中提取Company下的数组答案 0 :(得分:1)
像这样添加
JsonObject jobject = jArray.get(0);
JsonArray CompanyArray = (JsonArray)jobject.getAsJsonArray(Company);
你将从jArray获得公司阵列。