public byte[] toJsonByteArrayFromPdxInstance(PdxInstance pdxInstance) {
    try {
      PdxToJSON pj = new PdxToJSON(pdxInstance);
      return pj.getJSONByteArray();
    } catch (Exception e) {
      throw new JSONFormatterException("Could not create JSON document from PdxInstance", e);
    }
  }
Converts a PdxInstance into a JSON document in byte-array form

@param pdxInstance The PdxInstance to convert
@return the JSON byte array
@throws JSONFormatterException if unable to create the JSON document
geode-core/src/main/java/org/apache/geode/pdx/JSONFormatter.java