0

我正在使用 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 下的数组

4

1 回答 1

1

像这样添加

JsonObject jobject = jArray.get(0);
JsonArray CompanyArray = (JsonArray)jobject.getAsJsonArray(Company);

您将从 jArray 获得公司数组。

于 2012-11-06T10:57:11.080 回答