Package com.google.gson.stream

Examples of com.google.gson.stream.JsonToken


  }

  private void parseDistributions(JsonArray<JsonAttributes> distributions) throws DcatParseException, IOException {

    while (jsonReader.hasNext()) {
      JsonToken token = jsonReader.peek();
      switch (token) {
        case BEGIN_OBJECT:
          jsonReader.beginObject();
          parseDistribution(distributions);
          jsonReader.endObject();
View Full Code Here


  }

  private void parseDistribution(JsonArray<JsonAttributes> distributions) throws DcatParseException, IOException {
    JsonAttributes attributes = new JsonAttributes();
    while (jsonReader.hasNext()) {
      JsonToken token = jsonReader.peek();
      switch (token) {
        case NAME:
          parseAttribute(attributes);
          break;
        default:
View Full Code Here

  }

  private void parseAttribute(JsonAttributes attributes) throws DcatParseException, IOException {
    String attrName = jsonReader.nextName();
    while (jsonReader.hasNext()) {
      JsonToken token = jsonReader.peek();
      switch (token) {
        case STRING:
          attributes.put(attrName, new JsonAttribute(jsonReader.nextString()));
          return;
        case NUMBER:
View Full Code Here

        new TypeAdapterRuntimeTypeWrapper<V>(context, valueTypeAdapter, valueType);
      this.constructor = constructor;
    }

    public Map<K, V> read(JsonReader in) throws IOException {
      JsonToken peek = in.peek();
      if (peek == JsonToken.NULL) {
        in.nextNull();
        return null;
      }
View Full Code Here

    popStack(); // empty iterator
    popStack(); // object
  }

  @Override public boolean hasNext() throws IOException {
    JsonToken token = peek();
    return token != JsonToken.END_OBJECT && token != JsonToken.END_ARRAY;
  }
View Full Code Here

    stack.add(entry.getValue());
    return (String) entry.getKey();
  }

  @Override public String nextString() throws IOException {
    JsonToken token = peek();
    if (token != JsonToken.STRING && token != JsonToken.NUMBER) {
      throw new IllegalStateException("Expected " + JsonToken.STRING + " but was " + token);
    }
    return ((JsonPrimitive) popStack()).getAsString();
  }
View Full Code Here

    expect(JsonToken.NULL);
    popStack();
  }

  @Override public double nextDouble() throws IOException {
    JsonToken token = peek();
    if (token != JsonToken.NUMBER && token != JsonToken.STRING) {
      throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token);
    }
    double result = ((JsonPrimitive) peekStack()).getAsDouble();
    if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) {
View Full Code Here

    popStack();
    return result;
  }

  @Override public long nextLong() throws IOException {
    JsonToken token = peek();
    if (token != JsonToken.NUMBER && token != JsonToken.STRING) {
      throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token);
    }
    long result = ((JsonPrimitive) peekStack()).getAsLong();
    popStack();
View Full Code Here

    popStack();
    return result;
  }

  @Override public int nextInt() throws IOException {
    JsonToken token = peek();
    if (token != JsonToken.NUMBER && token != JsonToken.STRING) {
      throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token);
    }
    int result = ((JsonPrimitive) peekStack()).getAsInt();
    popStack();
View Full Code Here

  private ObjectTypeAdapter(Gson gson) {
    this.gson = gson;
  }

  @Override public Object read(JsonReader in) throws IOException {
    JsonToken token = in.peek();
    switch (token) {
    case BEGIN_ARRAY:
      List<Object> list = new ArrayList<Object>();
      in.beginArray();
      while (in.hasNext()) {
View Full Code Here

TOP

Related Classes of com.google.gson.stream.JsonToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.