Package com.google.gson.stream

Examples of com.google.gson.stream.JsonWriter.endArray()


                    Iterable<? extends Message> iterable = (Iterable<? extends Message>) object;
                    jsonWriter.beginArray();
                    for (Message msg : iterable) {
                        ProtobufJsonWriter.serialize(msg, jsonWriter);
                    }
                    jsonWriter.endArray();
                }
            }
        }
    }
}
View Full Code Here


          }
          writer.name("type").value(chan.getType().ordinal());
          writer.endObject();
        }
      }
      writer.endArray();
      writer.close();
    } catch (Exception e) {
      Log.error("Could not write Dimensional trasciever channels to " + getDataFile().getAbsolutePath() + " : " + e);
    }
  }
View Full Code Here

          JsonWriter jsonWriter = new JsonWriter(writer);
          jsonWriter.setIndent("  ");
          jsonWriter.beginArray();
          jsonWriter.value(event.getType().name());
          gson.toJson(event, event.getClass(), jsonWriter);
          jsonWriter.endArray();
          writer.write("\n\n");
        } catch (Throwable t) {
          // We can't do a stack bang here so any call is a risk of hitting SOE again.
          while (true) {
            doForcedShutdown = t;
View Full Code Here

        writer.beginArray();
        for (Map.Entry<UUID, WorkerInfo> i : workerStack.entrySet()) {
          adapter.setCurrentUUID(i.getKey());
          serializer.toJson(i.getValue(), WorkerInfo.class, writer);
        }
        writer.endArray();
        writer.close();
        outputStream.close();
        getLogger().log(Level.INFO, "Villagers information serialized.");
      } catch (Exception ex) {
        getLogger().log(Level.SEVERE, "Can't serialize villagers informations.", ex);
View Full Code Here

        if (limit > 0) {
          eventsRead = reader.read(events, getReadLimit(limit), 0, TimeUnit.SECONDS, readFilter);
        }
      }
      jsonWriter.endArray();
      jsonWriter.close();

      // Send the last chunk that still has data
      if (buffer.readable()) {
        responder.sendChunk(buffer);
View Full Code Here

          JsonWriter jsonWriter = new JsonWriter(writer);
          jsonWriter.setIndent("  ");
          jsonWriter.beginArray();
          jsonWriter.value(event.getType().name());
          gson.toJson(event, event.getClass(), jsonWriter);
          jsonWriter.endArray();
        } catch (Throwable t) {
          Closeables.closeQuietly(writer);
          writer = null;

          SlaveMain.warn("Unhandled exception in event serialization.", t);
View Full Code Here

          JsonWriter jsonWriter = new JsonWriter(writer);
          jsonWriter.setIndent("  ");
          jsonWriter.beginArray();
          jsonWriter.value(event.getType().name());
          gson.toJson(event, event.getClass(), jsonWriter);
          jsonWriter.endArray();
        } catch (Throwable t) {
          Closeables.close(writer, false);
          writer = null;

          SlaveMain.warn("Unhandled exception in event serialization.", t);
View Full Code Here

          JsonWriter jsonWriter = new JsonWriter(writer);
          jsonWriter.setIndent("  ");
          jsonWriter.beginArray();
          jsonWriter.value(event.getType().name());
          gson.toJson(event, event.getClass(), jsonWriter);
          jsonWriter.endArray();
          jsonWriter.flush();
        } catch (Throwable t) {
          SlaveMain.warn("Unhandled exception in event serialization.", t);

          Closeables.closeQuietly(writer);
View Full Code Here

                for (Variable variable : vars) {
                    Formatter formatter = _snitch.getFormatter(variable);
                    formatter.format(variable.getValue(), writer);
                }
                if (vars.size() > 1) {
                    writer.endArray();
                }
            }
            writer.endObject();
        } finally {
            Closeables.closeQuietly(writer);
View Full Code Here

            for (WrappedStack wrappedStack : energyValueMap.keySet())
            {
                jsonSerializer.toJson(new EnergyValueStackMapping(wrappedStack, energyValueMap.get(wrappedStack)), EnergyValueStackMapping.class, jsonWriter);
            }

            jsonWriter.endArray();
            jsonWriter.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.