Package com.google.gson.stream

Examples of com.google.gson.stream.JsonToken


       
      }//TESTED
      else {
        if (bRecurse) {
       
          JsonToken tok = reader.peek();
          if (JsonToken.BEGIN_OBJECT == tok) {
            getDocumentsFromJson(reader, parser, docList, true, textOnly);
          }//TESTED
          else if (JsonToken.BEGIN_ARRAY == tok) {
            reader.beginArray();         
            while (reader.hasNext()) {
              JsonToken tok2 = reader.peek();
             
              if (JsonToken.BEGIN_OBJECT == tok2) {
                getDocumentsFromJson(reader, parser, docList, true, textOnly);             
              }
              else {
View Full Code Here


       
      }//TESTED
      else {
        if (bRecurse) { //TODO (INF-2469): Not currently supported, it gets a bit tricky? (need to convert to a stack)
       
          JsonToken tok = reader.peek();
          if (JsonToken.BEGIN_OBJECT == tok) {
            BasicDBObject currObj = getDocumentFromJson(true);
            if (null != currObj) {
              return currObj;
            }
          }//TESTED
          else if (JsonToken.BEGIN_ARRAY == tok) {
            reader.beginArray();         
            while (reader.hasNext()) {
              JsonToken tok2 = reader.peek();
             
              if (JsonToken.BEGIN_OBJECT == tok2) {
                BasicDBObject currObj = getDocumentFromJson(true);
                if (null != currObj) {
                  return currObj;
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

        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

      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

        }

        @Override
        public String read(JsonReader jsonReader) throws IOException {
            final JsonToken token = jsonReader.peek();
            String s = null;
            switch (token) {
                case BEGIN_OBJECT:
                    jsonReader.beginObject();
                    while (jsonReader.hasNext()) {
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

      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

    gson = Serializer.createGSon(refLoader);
  }

  public IEvent deserialize() throws IOException {
    JsonToken peek = input.peek();
    if (peek == JsonToken.END_ARRAY)
      return null;

    input.beginArray();
    EventType type = EventType.valueOf(input.nextString());
View Full Code Here

      InputStream is = new BufferedInputStream(new FileInputStream(inputFile));
      closer.register(is);
      JsonReader input = new JsonReader(new InputStreamReader(is, Charsets.UTF_8));
      input.setLenient(true);

      JsonToken peek;
      while (true) {
        peek = input.peek();
       
        if (peek == JsonToken.END_DOCUMENT) {
          return;
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.