Example usage for com.google.gson JsonArray get

List of usage examples for com.google.gson JsonArray get

Introduction

In this page you can find the example usage for com.google.gson JsonArray get.

Prototype

public JsonElement get(int i) 

Source Link

Document

Returns the ith element of the array.

Usage

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getSimplePolygon(Location location, JsonArray array) {
    for (int i = 0; i < array.size(); i++) {
        JsonObject ob = array.get(i).getAsJsonObject();

        Geometry g = new Geometry();
        g.setPosList(ob.get(SIMPLE_POLYGON).getAsJsonObject().get(POS_LIST).getAsString());

        Polygon polygon = new Polygon();
        polygon.setTerm(ob.get(TERM).getAsString());
        polygon.setSimplePolygon(g);/*from  w w  w .ja v a2  s.com*/

        location.addPolygon(polygon);
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getRelationships(Location location, JsonArray array) {
    for (int i = 0; i < array.size(); i++) {
        JsonObject ob = array.get(i).getAsJsonObject();

        Relationship r = new Relationship();
        r.setTerm(ob.get(TERM).getAsString());
        r.setBase(ob.get(BASE).getAsString());
        if (ob.has(TARGET_POI))
            r.setTargetPOI(ob.get(TARGET_POI).getAsString());

        if (ob.has(TARGET_EVENT))
            r.setTargetEvent(ob.get(TARGET_EVENT).getAsString());

        location.addRelationship(r);//  ww w  . j  av  a2 s.co  m
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getTime(POI poi, JsonObject jObject) {
    JsonArray jArray = jObject.getAsJsonArray(TIME);
    for (int i = 0; i < jArray.size(); i++) {
        JsonObject ob = jArray.get(i).getAsJsonObject();
        POITermType term = getPOITermType(ob);

        if (ob.has(SCHEME))
            term.setScheme(ob.get(SCHEME).getAsString());

        poi.addTime(term);/*from  w  ww  .  ja v  a  2  s  .c  om*/
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getLinks(POI poi, JsonObject jObject) {
    JsonArray jArray = jObject.getAsJsonArray(LINK);
    for (int i = 0; i < jArray.size(); i++) {
        JsonObject ob = jArray.get(i).getAsJsonObject();
        POITermType term = getPOITermType(ob);
        poi.addLink(term);/* ww  w .ja v  a2  s. c o m*/
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void deserializeListPois(ListPointOfInterest list, JsonObject jObject) {
    JsonElement jElement = jObject.get(POI);
    JsonArray jArray = jElement.getAsJsonArray();
    for (int i = 0; i < jArray.size(); i++) {
        PointOfInterest poi = new PointOfInterest();
        getSinglePOI(poi, jArray.get(i).getAsJsonObject());
        list.addPoi(poi);//from  w  w  w  .j  a  va  2  s  .  com
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void deserializeListEvents(ListEvent list, JsonObject jObject) {
    JsonElement jElement = jObject.get(EVENT);
    JsonArray jArray = jElement.getAsJsonArray();
    for (int i = 0; i < jArray.size(); i++) {
        Event event = new Event();
        getSinglePOI(event, jArray.get(i).getAsJsonObject());
        list.addEvent(event);/*from  w  w  w .java 2 s  .  com*/
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void deserializeListRoutes(ListRoute list, JsonObject jObject) {
    JsonElement jElement = jObject.get(ROUTES);
    JsonArray jArray = jElement.getAsJsonArray();
    for (int i = 0; i < jArray.size(); i++) {
        Route route = new Route();
        getSinglePOI(route, jArray.get(i).getAsJsonObject());
        list.addRoute(route);//from  ww w  .ja  v  a  2 s  .c o  m
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void deserializePoiBased(Deserializable poi, JsonObject json) {
    getSinglePOI((POI) poi, json);/*ww w.  j  a  va2 s.com*/

    // for routes
    if (json.has(POIS)) {
        JsonArray jArray = json.get(POIS).getAsJsonArray();
        ListPointOfInterest list = ((Route) poi).getListPoi();
        for (int i = 0; i < jArray.size(); i++) {
            PointOfInterest rPoi = new PointOfInterest();
            getSinglePOI(rPoi, jArray.get(i).getAsJsonObject());
            list.addPoi(rPoi);
        }
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void deserializeResources(Resources resources, JsonObject jObject) {
    JsonElement jElement = jObject.get(TOURISM);
    JsonArray jArray = jElement.getAsJsonArray();
    for (int i = 0; i < jArray.size(); i++) {
        JsonObject ob = jArray.get(i).getAsJsonObject();
        HypermediaLink resource = getResource(ob);
        resources.addResource(resource);
    }//from   www .j  a v a2s  .  c om
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private POI deserializeCategories(Category list, JsonElement elem) {
    JsonObject json = null;/*w w w.  jav  a2 s  .c  o m*/
    JsonArray array;

    if (elem.isJsonObject() && elem.getAsJsonObject().has(CATEGORIES)) {
        array = elem.getAsJsonObject().get(CATEGORIES).getAsJsonArray();
        for (int i = 0; i < array.size(); i++) {
            Category cat = new Category();
            json = array.get(i).getAsJsonObject();
            getSinglePOI(cat, json);
            if (json.has(CATEGORIES)) {
                Category subs = (Category) deserializeCategories(new Category(), json);
                for (int j = 0; j < subs.getNumCategories(); j++)
                    cat.addCategory(subs.getCategory(j));
            }

            list.addCategory(cat);
        }
    }

    return list;
}