@SuppressWarnings("unchecked") public YahooJsonDeserializer() { jsonDeserializer = new JSONDeserializer() .use(null, YahooGeocoderResults.class); }
public static LoanShark fromJsonToLoanShark(String json) { return new JSONDeserializer<LoanShark>().use(null, LoanShark.class).deserialize(json); }
public static String toJsonArray(Collection<LoanShark> collection) { return new JSONSerializer().exclude("*.class").serialize(collection); }
/** * Constructor * @param manager */ public JSONTranscoder(final Manager manager) { serializer = new JSONSerializer(); deserializer = new JSONDeserializer<ConcurrentMap<String, Object>>(); if (LOG.isDebugEnabled()) { LOG.debug("Initialized json serializer"); } }
public List<NominatimGeocoderResult> parseResults(String content) { return jsonDeserializer.deserialize(content); } }
/** * This performs a shallow serialization of the target instance and * passes the generated JSON into the provided StringBuilder. * * @param target - the instance to serialize to JSON * @param out - StringBuilder to write output to * @return returns JSON as a String */ public String serialize(Object target, StringBuilder out) { return serialize(target, SerializationType.SHALLOW, new StringBuilderOutputHandler(out)); }
/** * This performs a shallow serialization of the target instance and * passes the generated JSON into the provided StringBuffer. * * @param target - the instance to serialize to JSON * @param out - StringBuffer to write output to * @return returns JSON as a String */ public String serialize(Object target, StringBuffer out) { return serialize(target, SerializationType.SHALLOW, new StringBufferOutputHandler(out)); }
/** * Deserialize the given json formatted input into a Java object. * * @param input a json formatted string. * @return an Java instance deserialized from the json input. */ public T deserialize(String input) { ObjectBinder binder= createObjectBinder(); return (T) binder.bind(new JSONTokener(input).nextValue()); }
@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 void writeName(String name) { if (prettyPrint) writeIndent(); if (name != null) writeQuoted(name); else write("null"); out.write(":"); if (prettyPrint) out.write(" "); }
public Method getReadMethod() { if (readMethod == null && bean.getSuperBean() != null && bean.getSuperBean().hasProperty(name)) { return bean.getSuperBean().getProperty(name).getReadMethod(); } else { return readMethod; } }
/** * Make a JSONException to signal a syntax error. * * @param message The error message. * @return A JSONException object, suitable for throwing */ public JSONException syntaxError(String message) { return new JSONException(message + toString()); }
/** * Return the deserialized map * * @param in bytes to deserialize * @return map of deserialized objects */ @Override public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in) { final InputStreamReader inputStream = new InputStreamReader( new ByteArrayInputStream( in ) ); if (LOG.isDebugEnabled()) { LOG.debug("deserialize the stream"); } try { return deserializer.deserializeInto(inputStream, new ConcurrentHashMap<String, Object>()); } catch( final RuntimeException e) { LOG.warn("Caught Exception deserializing JSON "+e); throw new TranscoderDeserializationException(e); } }
public static Collection<LoanShark> fromJsonArrayToLoanSharks(String json) { return new JSONDeserializer<List<LoanShark>>().use(null, ArrayList.class).use("values", LoanShark.class).deserialize(json); }
public String toJson() { return new JSONSerializer().exclude("*.class").serialize(this); }
public GoogleJsonDeserializer() { jsonDeserializer = new JSONDeserializer<GoogleGeocoderResults>() .use(null, GoogleGeocoderResults.class); }
public YahooGeocoderResults parseResults(String json) { return (YahooGeocoderResults) jsonDeserializer.deserialize(json); } }
/** * Same as {@link #deserialize(String)}, but uses an instance of * java.io.Reader as json input. * * @param input the stream where the json input is coming from. * @return an Java instance deserialized from the java.io.Reader's input. */ public T deserialize(Reader input) { ObjectBinder binder= createObjectBinder(); return (T) binder.bind(new JSONTokener(input).nextValue()); }
public NominatimJsonDeserializer() { jsonDeserializer = new JSONDeserializer<List<NominatimGeocoderResult>>().use("values", NominatimGeocoderResult.class); }
public GoogleGeocoderResults parseResults(String content) { return (GoogleGeocoderResults) jsonDeserializer.deserialize(content); } }