@Override public Object from(Repository r, String json, Type type) { return genson.deserialize(json, GenericType.of(type)); }
public <T> T deserialize(String fromSource, Class<T> toType, Class<? extends BeanView<?>>... withViews) { StringReader reader = new StringReader(fromSource); return deserialize(GenericType.of(toType), createReader(reader), new Context(this, Arrays.asList(withViews))); }
/** * @see #deserializeValues(com.owlike.genson.stream.ObjectReader, GenericType) */ public <T> Iterator<T> deserializeValues(final InputStream is, final Class<T> type) { return deserializeValues(createReader(is), GenericType.of(type)); }
/** * @see #deserializeValues(com.owlike.genson.stream.ObjectReader, GenericType) */ public <T> Iterator<T> deserializeValues(final InputStream is, final Class<T> type) { return deserializeValues(createReader(is), GenericType.of(type)); }
public <T> T deserialize(String fromSource, Class<T> toType, Class<? extends BeanView<?>>... withViews) { StringReader reader = new StringReader(fromSource); return deserialize(GenericType.of(toType), createReader(reader), new Context(this, Arrays.asList(withViews))); }
/** * Deserializes fromSource String into an instance of toClass. * * @param fromSource source from which to deserialize. * @param toClass type into which to deserialize. * @throws com.owlike.genson.JsonBindingException * @throws JsonStreamException */ public <T> T deserialize(String fromSource, Class<T> toClass) { return deserialize(GenericType.of(toClass), createReader(new StringReader(fromSource)), new Context(this)); }
/** * Deserializes fromSource String into an instance of toClass. * * @param fromSource source from which to deserialize. * @param toClass type into which to deserialize. * @throws com.owlike.genson.JsonBindingException * @throws JsonStreamException */ public <T> T deserialize(String fromSource, Class<T> toClass) { return deserialize(GenericType.of(toClass), createReader(new StringReader(fromSource)), new Context(this)); }
/** * Deserializes the incoming json stream into an instance of T. * Genson did not create the instance of Reader so it will not be closed */ public <T> T deserialize(Reader reader, Class<T> toType) { return deserialize(GenericType.of(toType), createReader(reader), new Context(this)); }
/** * Deserializes the incoming json stream into an instance of T. * Genson did not create the instance of Reader so it will not be closed */ public <T> T deserialize(Reader reader, Class<T> toType) { return deserialize(GenericType.of(toType), createReader(reader), new Context(this)); }
/** * Deserializes the incoming json byte array into an instance of T. */ public <T> T deserialize(byte[] input, Class<T> toType) { return deserialize(GenericType.of(toType), createReader(input), new Context(this)); }
public Object deserialize(ObjectReader reader, Context ctx) { return ctx.genson.deserialize(GenericType.of(reader.getValueType().toClass()), reader, ctx); }
public Object deserialize(ObjectReader reader, Context ctx) { return ctx.genson.deserialize(GenericType.of(reader.getValueType().toClass()), reader, ctx); }
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { try { Genson genson = getInstance(type); ObjectReader reader = genson.createReader(entityStream); return genson.deserialize(GenericType.of(rawIfNullGenericType(type, genericType)), reader, createContext(annotations, genson)); } catch (JsonBindingException e) { throw new WebApplicationException(e); } catch (JsonStreamException jse) { throw new WebApplicationException(jse); } }
/** * Deserializes the incoming json stream into an instance of T. * Genson did not create the instance of InputStream so it will not be closed */ public <T> T deserialize(InputStream input, Class<T> toType) { return deserialize(GenericType.of(toType), createReader(input), new Context(this)); }
/** * Deserializes the incoming json byte array into an instance of T. */ public <T> T deserialize(byte[] input, Class<T> toType) { return deserialize(GenericType.of(toType), createReader(input), new Context(this)); }
/** * Deserializes the incoming json stream into an instance of T. * Genson did not create the instance of InputStream so it will not be closed */ public <T> T deserialize(InputStream input, Class<T> toType) { return deserialize(GenericType.of(toType), createReader(input), new Context(this)); }
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { try { Genson genson = getInstance(type); ObjectReader reader = genson.createReader(entityStream); return genson.deserialize(GenericType.of(rawIfNullGenericType(type, genericType)), reader, createContext(annotations, genson)); } catch (JsonBindingException e) { throw new WebApplicationException(e); } catch (JsonStreamException jse) { throw new WebApplicationException(jse); } }
@Override protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { MethodParameter mp = ThreadLocalHolder.get("__GENSON$method_param", MethodParameter.class); WithBeanView ann = null; Type type = clazz; if (mp != null) { ann = mp.getMethodAnnotation(WithBeanView.class); type = mp.getGenericParameterType(); } GenericType<?> genericType = GenericType.of(type); if (ann != null) return genson.deserialize(genericType, genson.createReader(inputMessage.getBody()), new Context(genson, Arrays.asList(ann.views()))); else return genson.deserialize(genericType, genson.createReader(inputMessage.getBody()), new Context(genson)); }
@Override protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { MethodParameter mp = ThreadLocalHolder.get("__GENSON$method_param", MethodParameter.class); WithBeanView ann = null; Type type = clazz; if (mp != null) { ann = mp.getMethodAnnotation(WithBeanView.class); type = mp.getGenericParameterType(); } GenericType<?> genericType = GenericType.of(type); if (ann != null) return genson.deserialize(genericType, genson.createReader(inputMessage.getBody()), new Context(genson, Arrays.asList(ann.views()))); else return genson.deserialize(genericType, genson.createReader(inputMessage.getBody()), new Context(genson)); }