* @throws IOException
* TODO: move this to a custom serializer?
*/
private static String toJSON(BucketProperties bp) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
JsonGenerator jg = new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8);
jg.writeStartObject();
writeIfNotNull(jg, bp.getAllowSiblings(), Constants.FL_SCHEMA_ALLOW_MULT);
writeIfNotNull(jg, bp.getNVal(), Constants.FL_SCHEMA_NVAL);
writeIfNotNull(jg, bp.getLastWriteWins(), Constants.FL_SCHEMA_LAST_WRITE_WINS);
writeIfNotNull(jg, bp.getBackend(), Constants.FL_SCHEMA_BACKEND);
writeIfNotNull(jg, bp.getSmallVClock(), Constants.FL_SCHEMA_SMALL_VCLOCK);
writeIfNotNull(jg, bp.getBigVClock(), Constants.FL_SCHEMA_BIG_VCLOCK);
writeIfNotNull(jg, bp.getYoungVClock(), Constants.FL_SCHEMA_YOUNG_VCLOCK);
writeIfNotNull(jg, bp.getOldVClock(), Constants.FL_SCHEMA_OLD_VCLOCK);
writeIfNotNull(jg, bp.getR(), Constants.FL_SCHEMA_R);
writeIfNotNull(jg, bp.getRW(), Constants.FL_SCHEMA_RW);
writeIfNotNull(jg, bp.getW(), Constants.FL_SCHEMA_W);
writeIfNotNull(jg, bp.getDW(), Constants.FL_SCHEMA_DW);
writeIfNotNull(jg, bp.getPR(), Constants.FL_SCHEMA_PR);
writeIfNotNull(jg, bp.getPW(), Constants.FL_SCHEMA_PW);
writeIfNotNull(jg, bp.getBasicQuorum(), Constants.FL_SCHEMA_BASIC_QUORUM);
writeIfNotNull(jg, bp.getNotFoundOK(), Constants.FL_SCHEMA_NOT_FOUND_OK);
writeIfNotNull(jg, bp.getChashKeyFunction(), Constants.FL_SCHEMA_CHASHFUN);
writeIfNotNull(jg, bp.getLinkWalkFunction(), Constants.FL_SCHEMA_LINKFUN);
writeIfNotNull(jg, bp.getPostcommitHooks(), Constants.FL_SCHEMA_POSTCOMMIT);
writeIfNotNull(jg, bp.getPrecommitHooks(), Constants.FL_SCHEMA_PRECOMMIT);
writeIfNotNull(jg, bp.getSearch(), Constants.FL_SCHEMA_SEARCH);
jg.writeEndObject();
jg.flush();
return CharsetUtils.asUTF8String(out.toByteArray());
}