Exemplo n.º 1
0
  public static String convertCollectionToJson(Collection<Object> collection) throws JSONException {
    HeapDataOutputStream outputStream =
        new HeapDataOutputStream(com.gemstone.gemfire.internal.Version.CURRENT);

    try {
      JsonGenerator generator =
          enableDisableJSONGeneratorFeature(
              getObjectMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8));
      JsonWriter.writeCollectionAsJson(generator, collection);
      generator.close();
      return new String(outputStream.toByteArray());
    } catch (IOException e) {
      throw new RuntimeException(e.getMessage());
    } finally {
      outputStream.close();
    }
  }
Exemplo n.º 2
0
 public static String formulateJsonForListFunctionsCall(Set<String> functionIds) {
   HeapDataOutputStream outputStream =
       new HeapDataOutputStream(com.gemstone.gemfire.internal.Version.CURRENT);
   try {
     JsonGenerator generator =
         enableDisableJSONGeneratorFeature(
             getObjectMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8));
     generator.writeStartObject();
     generator.writeFieldName("functions");
     JsonWriter.writeCollectionAsJson(generator, functionIds);
     generator.writeEndObject();
     generator.close();
     return new String(outputStream.toByteArray());
   } catch (IOException e) {
     throw new RuntimeException(e.getMessage());
   } finally {
     outputStream.close();
   }
 }
Exemplo n.º 3
0
  public static String formulateJsonForGetOnMultipleKey(
      Collection<Object> collection, String regionName) throws JSONException {
    HeapDataOutputStream outputStream =
        new HeapDataOutputStream(com.gemstone.gemfire.internal.Version.CURRENT);

    try {
      JsonGenerator generator =
          enableDisableJSONGeneratorFeature(
              getObjectMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8));
      generator.writeStartObject();
      generator.writeFieldName(regionName);
      JsonWriter.writeCollectionAsJson(generator, collection);
      generator.writeEndObject();
      generator.close();
      return new String(outputStream.toByteArray());
    } catch (IOException e) {
      throw new RuntimeException(e.getMessage());
    } finally {
      outputStream.close();
    }
  }