@Override public byte[] serializeAttributes(final MemcachedBackupSession sessions, final ConcurrentMap<String, Object> attributes) { if (attributes == null) { throw new NullPointerException(); } final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { // This performs a deep serialization of the target instance. // It's serialized to a string as flexjson doesn't like writing to // an OutputStreamWriter: it throws the exception "Stepping back two steps is not supported". // See https://github.com/moresandeep/memcached-session-manager/commit/db2faaa0a846e16d65ac0b14819689c67bf92c68#commitcomment-512505 final String serResult = serializer.deepSerialize(attributes); if (LOG.isDebugEnabled()) { LOG.debug("JSON Serialised object: " + serResult); } return serResult.getBytes(); // converts to bytes } catch (final Exception e) { LOG.warn("Caught Exception deserializing JSON " + e); throw new IllegalArgumentException(); } finally { close(bos); } }
public String serialize(Object object) { return jsonSerializer.deepSerialize(object); }
protected String encodeToJSON() { JSONSerializer serializer = new JSONSerializer(); return serializer.deepSerialize( this ); }
@Override public void writeTo( IDatabaseConnectionList t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream ) throws IOException, WebApplicationException { OutputStreamWriter outputStreamWriter = new OutputStreamWriter( entityStream ); try { new JSONSerializer().exclude( "*.class" ).deepSerialize( t, outputStreamWriter ); } finally { outputStreamWriter.close(); } }
@Override public void writeTo( IDatabaseTypesList t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream ) throws IOException, WebApplicationException { OutputStreamWriter outputStreamWriter = new OutputStreamWriter( entityStream ); try { new JSONSerializer().exclude( "*.class" ).deepSerialize( t, outputStreamWriter ); } finally { outputStreamWriter.close(); } }
/** * Returns a JSON list of the available business models * * @param domainName optional domain to limit the results * @return JSON string of list of ModelInfo objects representing the available models * @throws IOException */ public String listBusinessModelsJson( String domainName ) throws IOException { ModelInfo[] models = listBusinessModels( domainName ); JSONSerializer serializer = new JSONSerializer(); String json = serializer.deepSerialize( models ); return json; }
/** * Returns a JSON Model object for the requested model. The model will include the basic metadata - categories and * columns. * * @param domainId * @param modelId * @return JSON string of the model */ public String loadModelJson( String domainId, String modelId ) { Model model = loadModel( domainId, modelId ); JSONSerializer serializer = new JSONSerializer(); String json = serializer.deepSerialize( model ); return json; }
/** * Executes a XML query and returns a JSON serialization of the result set * * @param rowLimit * @return */ public String doXmlQueryToJson( String xml, int rowLimit ) { MarshallableResultSet resultSet = doXmlQuery( xml, rowLimit ); if ( resultSet == null ) { return null; } JSONSerializer serializer = new JSONSerializer(); String json = serializer.deepSerialize( resultSet ); return json; }
@Benchmark @Override public Object flexjson() { StringBuilder b = JsonUtils.stringBuilder(); JSON_SOURCE().provider().flexjsonSer().exclude("*.class").deepSerialize(JSON_SOURCE().nextPojo(), b); return b; }