Package com.google.gson.stream

Examples of com.google.gson.stream.JsonToken


        // this *HAS* to start as an object
        reader.beginObject();

        while (reader.hasNext()) {
            JsonToken tok = reader.peek();
            switch (tok) {
                case NAME:
                    String name = reader.nextName();
                    // find out which member it is
                    if (name.equals(CLIENTS)) {
View Full Code Here


    JsonReader reader = new JsonReader(in);

    reader.beginObject();

    while (reader.hasNext()) {
      JsonToken tok = reader.peek();
      switch (tok) {
        case NAME:
          String name = reader.nextName();
          if (name.equals(MITREidDataService.MITREID_CONNECT_1_0)) {
            dataService_1_0.importData(reader);
View Full Code Here

        // this *HAS* to start as an object
        reader.beginObject();

        while (reader.hasNext()) {
            JsonToken tok = reader.peek();
            switch (tok) {
                case NAME:
                    String name = reader.nextName();
                    // find out which member it is
                    if (name.equals(CLIENTS)) {
View Full Code Here

      try {
         reader = new JsonReader(new InputStreamReader(arg0.getPayload().getInput()));
         // in case keys are not in quotes
         reader.setLenient(true);
         AtomicReference<String> name = Atomics.newReference();
         JsonToken token = reader.peek();
         for (; token != JsonToken.END_DOCUMENT && nnn(reader, token, name); token = skipAndPeek(token, reader)) {
         }
         if (name.get() == null) {
            logger.trace("did not object named %s in json from response %s", nameChoices, arg0);
            return nothing();
View Full Code Here

      assertEquals(val.toString(), "[(name=GREETINGS, source=guest)]");
   }

   protected <T> T parseThingFromReaderOrNull(String toFind, JsonReader reader, Type type) throws IOException {
      AtomicReference<String> name = Atomics.newReference();
      JsonToken token = reader.peek();
      for (; token != JsonToken.END_DOCUMENT && nnn(toFind, reader, token, name); token = skipAndPeek(token, reader))
         ;
      T val = gson.<T> fromJson(reader, type);
      reader.close();
      return val;
View Full Code Here

    valuesQueueStart = ref.next;
    return ref;
  }

  private void expect(final JsonToken token) throws IOException {
    final JsonToken actual = peek();
    this.token = null;
    if (actual != token) { throw new IllegalStateException(token + " expected, but met " + actual + "\n" + dump()); }
  }
View Full Code Here

  public void skipValue() throws IOException {
    skipping = true;
    try {
      int count = 0;
      do {
        final JsonToken token = peek();
        if (token == JsonToken.BEGIN_ARRAY || token == JsonToken.BEGIN_OBJECT) {
          count++;
        } else if (token == JsonToken.END_ARRAY || token == JsonToken.END_OBJECT) {
          count--;
        } else if (valuesQueue != null) {
View Full Code Here

  public JsonReaderExt(Reader in) {
    super(in);
  }
 
  public void consumeExpected(JsonToken expectedToken) throws IOException {
    JsonToken tokenType = validateExpectedToken(expectedToken);
    if(tokenType == JsonToken.BEGIN_OBJECT) {
      jsonReader.beginObject();
    } else if(tokenType == JsonToken.END_OBJECT) {
      jsonReader.endObject();
    } else if(tokenType == JsonToken.BEGIN_ARRAY) {
View Full Code Here

      assertFail();
    }
  }
 
  protected JsonToken validateExpectedToken(JsonToken expectedToken) throws IOException, MalformedJsonException {
    JsonToken tokenType = jsonReader.peek();
    if(tokenType != expectedToken) {
      throw new MalformedJsonException("Expected: " + expectedToken + " Got: " + tokenType);
    }
    return tokenType;
  }
View Full Code Here

    jsonReader.consumeExpected(JsonToken.BEGIN_ARRAY);
   
    ArrayList<String> strings = new ArrayList<>();
   
    while(jsonReader.hasNext()) {
      JsonToken tokenType = jsonReader.peek();
     
      if(ignoreNulls && tokenType == JsonToken.NULL) {
        jsonReader.nextNull();
        continue;
      }
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.