private byte [ ] toStorageJson ( ) { // TODO - precalc how much memory to grab final ByteArrayOutputStream output = new ByteArrayOutputStream ( ) ; try { final JsonGenerator json = JSON . getFactory ( ) . createGenerator ( output ) ; json . writeStartObject ( ) ; // we only need to write a small amount of information //json.writeNumberField("treeId", tree_id); json . writeStringField ( "name" , name ) ; json . writeStringField ( "description" , description ) ; json . writeStringField ( "notes" , notes ) ; json . writeBooleanField ( "strictMatch" , strict_match ) ; json . writeNumberField ( "created" , created ) ; json . writeBooleanField ( "enabled" , enabled ) ; json . writeBooleanField ( "storeFailures" , store_failures ) ; json . writeEndObject ( ) ; json . close ( ) ; // TODO zero copy? return output . toByteArray ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Converts the object to a JSON byte array necessary for CAS calls and to keep redundant data down