@Override public Object from(Repository r, String json, Type type) { return genson.deserialize(json, GenericType.of(type)); }
public static <T> GenericType<T> of(Class<T> rawClass) { return new GenericType<T>(rawClass) { }; }
public <T> T deserialize(GenericType<T> type, ObjectReader reader, Context ctx) { Deserializer<T> deser = provideConverter(type.getType()); try { return deser.deserialize(reader, ctx); } catch (Exception e) { throw new JsonBindingException("Could not deserialize to type " + type.getRawClass(), e); } }
/** * Register converter by mapping it to the parameterized type of type argument. * * @param converter to register * @param type of objects this converter handles * @return a reference to this builder. */ public <T> GensonBuilder withConverter(Converter<T> converter, GenericType<? extends T> type) { registerConverter(converter, type.getType()); return this; }
@Override public T next() { if (!hasNext()) throw new NoSuchElementException(); reader.next(); try { return converter.deserialize(reader, ctx); } catch (Exception e) { throw new JsonBindingException("Could not deserialize to type " + type.getRawClass(), e); } }
public <T> GensonBuilder withDeserializer(Deserializer<T> deserializer, GenericType<? extends T> type) { registerDeserializer(deserializer, type.getType()); return this; }
@Override public T next() { if (!hasNext()) throw new NoSuchElementException(); reader.next(); try { return converter.deserialize(reader, ctx); } catch (Exception e) { throw new JsonBindingException("Could not deserialize to type " + type.getRawClass(), e); } }
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))); }
public <T> GensonBuilder withSerializer(Serializer<T> serializer, GenericType<? extends T> type) { registerSerializer(serializer, type.getType()); return this; }
public <T> T deserialize(GenericType<T> type, ObjectReader reader, Context ctx) { Deserializer<T> deser = provideConverter(type.getType()); try { return deser.deserialize(reader, ctx); } catch (Exception e) { throw new JsonBindingException("Could not deserialize to type " + type.getRawClass(), e); } }
public static GenericType<Object> of(Type type) { return new GenericType<Object>(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)); }
/** * Register converter by mapping it to the parameterized type of type argument. * * @param converter to register * @param type of objects this converter handles * @return a reference to this builder. */ public <T> GensonBuilder withConverter(Converter<T> converter, GenericType<? extends T> type) { registerConverter(converter, type.getType()); return this; }
public static <T> GenericType<T> of(Class<T> rawClass) { return new GenericType<T>(rawClass) { }; }
/** * @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> GensonBuilder withDeserializer(Deserializer<T> deserializer, GenericType<? extends T> type) { registerDeserializer(deserializer, type.getType()); return this; }
public static GenericType<Object> of(Type type) { return new GenericType<Object>(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))); }
public <T> GensonBuilder withSerializer(Serializer<T> serializer, GenericType<? extends T> type) { registerSerializer(serializer, type.getType()); return 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)); }