Example usage for com.google.gson.stream JsonReader endObject

List of usage examples for com.google.gson.stream JsonReader endObject

Introduction

In this page you can find the example usage for com.google.gson.stream JsonReader endObject.

Prototype

public void endObject() throws IOException 

Source Link

Document

Consumes the next token from the JSON stream and asserts that it is the end of the current object.

Usage

From source file:zack.yovel.clear.infrastructure.model.datapoints.ForecastIoParser.java

License:Apache License

private void doParse(JsonReader reader, WeatherReport output) throws IOException {
    reader.beginObject();//from   www .jav  a 2s . c om
    while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals("latitude")) {
            output.setLatitude(reader.nextDouble());
        } else if (name.equals("longitude")) {
            output.setLongitude(reader.nextDouble());
        } else if (name.equals("currently")) {
            output.setCurrently(parseDataPoint(reader));
        } else if (name.equals("hourly")) {
            output.setHourly(parseDataBlock(reader));
        } else if (name.equals("daily")) {
            output.setDaily(parseDataBlock(reader));
        } else if (name.equals("alerts")) {
            output.setAlerts(parseAlerts(reader));
        } else {
            reader.skipValue();
        }
    }
    reader.endObject();
}

From source file:zack.yovel.clear.infrastructure.model.datapoints.ForecastIoParser.java

License:Apache License

private Alert parseAlert(JsonReader reader) throws IOException {
    Alert output = new Alert();
    reader.beginObject();//from  w ww  .  j a v a2  s  .  c  o  m
    String name = reader.nextName();
    if (name.equals("title")) {
        output.setTitle(reader.nextString());
    } else if (name.equals("expires")) {
        output.setExpires(reader.nextLong());
    } else if (name.equals("description")) {
        output.setDescription(reader.nextString());
    } else if (name.equals("uri")) {
        output.setUri(reader.nextString());
    } else {
        reader.skipValue();
    }
    reader.endObject();
    return output;
}

From source file:zack.yovel.clear.infrastructure.model.datapoints.ForecastIoParser.java

License:Apache License

private DataBlock parseDataBlock(JsonReader reader) throws IOException {
    DataBlock output = new DataBlock();
    reader.beginObject();/*  w w  w.j  a v a2s .c om*/
    while (reader.hasNext()) {
        JsonToken token = reader.peek();
        if (token == JsonToken.END_OBJECT) {
            break;
        }
        getDataBlockProperty(reader, output);
    }
    reader.endObject();
    return output;
}

From source file:zack.yovel.clear.infrastructure.model.datapoints.ForecastIoParser.java

License:Apache License

private DataPoint parseDataPoint(JsonReader reader) throws IOException {
    DataPoint output = new DataPoint();
    reader.beginObject();/*ww w  . jav  a2 s  . c o  m*/
    boolean exit = false;
    while (!exit && reader.hasNext()) {
        JsonToken token = reader.peek();
        if (token == JsonToken.END_OBJECT) {
            break;
        }
        getDataPointProperty(reader, output);
    }
    reader.endObject();
    return output;
}