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(); } }
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(); } }
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(); } }