Package com.google.gson.stream

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


        try
        {
            jsonWriter = new JsonWriter(new FileWriter(jsonFile));
            jsonWriter.setIndent("    ");
            jsonWriter.beginArray();
            for (WrappedStack wrappedStack : energyValueMap.keySet())
            {
                jsonSerializer.toJson(new EnergyValueStackMapping(wrappedStack, energyValueMap.get(wrappedStack)), EnergyValueStackMapping.class, jsonWriter);
            }
View Full Code Here


      // See GH-92 for more info.
      final StringWriter sw = new StringWriter();
      try {
        final JsonWriter jsonWriter = new JsonWriter(sw);
        jsonWriter.setIndent("  ");
        jsonWriter.beginArray();
        jsonWriter.value(event.getType().name());
        gson.toJson(event, event.getClass(), jsonWriter);
        jsonWriter.endArray();
        jsonWriter.close();
      } catch (Throwable t) {
View Full Code Here

  {

    StringWriter swriter = new StringWriter();
    JsonWriter jwriter = new JsonWriter(swriter);
       jwriter.setIndent(" ");
    jwriter.beginArray();
   
    SerializeLLSDJsonElement(jwriter, data);
   
    jwriter.endArray();
   
View Full Code Here

      json.name("data");
      json.beginObject();
      for (Map.Entry<Class<? extends HasUuid>, List<HasUuid>> entry : collate(
          context.getEntities()).entrySet()) {
        json.name(typeContext.describe(entry.getKey()).getTypeName());
        json.beginArray();
        for (HasUuid value : entry.getValue()) {
          if (persistenceMapper.isPersisted(value)) {
            persistent.add(value);
          }
          visitors.visit(this, value);
View Full Code Here

      }

      // Write metadata for any entities
      if (!persistent.isEmpty()) {
        json.name("metadata");
        json.beginArray();
        for (HasUuid toWrite : persistent) {
          EntityMetadata meta = new EntityMetadata();
          meta.setPersistent(true);
          meta.setUuid(toWrite.getUuid());
          visitors.visit(this, meta);
View Full Code Here

  }

  @Override
  public void writeNotNull(Object object, SerializationContext context) throws Exception {
    JsonWriter writer = context.getWriter();
    writer.beginArray();
    for (int i = 0, j = Array.getLength(object); i < j; i++) {
      context.pushPath("[" + i + "]");
      valueCodex.write(boxedType.cast(Array.get(object, i)), context);
      context.popPath();
    }
View Full Code Here

  }

  @Override
  public void writeNotNull(T collection, SerializationContext context) throws IOException {
    JsonWriter writer = context.getWriter();
    writer.beginArray();
    int count = 0;
    for (V t : collection) {
      context.pushPath("[" + count++ + "]");
      valueCodex.write(t, context);
      context.popPath();
View Full Code Here

  }

  @Override
  public void writeNotNull(T[] object, SerializationContext context) throws IOException {
    JsonWriter writer = context.getWriter();
    writer.beginArray();
    int count = 0;
    for (T t : object) {
      context.pushPath("[" + count++ + "]");
      valueCodex.write(t, context);
      context.popPath();
View Full Code Here

  public static <T> void writeObjectsToStreamAsJson(Gson gson, OutputStream out, List<T> list)
      throws IOException {

    JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, "UTF-8"));
    writer.setIndent("  ");
    writer.beginArray();
    for (T t : list) {
      gson.toJson(t, t.getClass(), writer);
    }
    writer.endArray();
    writer.close();
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.