Tabnine Logo
com.owlike.genson
Code IndexAdd Tabnine to your IDE (free)

How to use com.owlike.genson

Best Java code snippets using com.owlike.genson (Showing top 20 results out of 315)

origin: Vedenin/useful-java-links

public static void main(String[] args) throws IOException {
  // init class
  Place place = new Place();
  place.setName("World");
  Human human = new Human();
  human.setMessage("Hi");
  human.setPlace(place);
  // convert to json
  String jsonString = new Genson().serialize(human);
  System.out.println("json " + jsonString); //print "json {"message":"Hi","place":{"name":"World"}}"
  // convert from json
  Human newHuman =  new Genson().deserialize(jsonString, Human.class);
  newHuman.say(); // print "Hi , World!"
}
origin: owlike/genson

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);
 }
}
origin: owlike/genson

/**
 * 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));
}
origin: com.owlike/genson

/**
 * 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, GenericType<T> toType) {
 return deserialize(toType, createReader(input), new Context(this));
}
origin: com.owlike/genson

/**
 * @see #deserializeInto(com.owlike.genson.stream.ObjectReader, Object, Context)
 */
public <T> T deserializeInto(byte[] jsonBytes, T object) {
 return deserializeInto(createReader(jsonBytes), object, new Context(this));
}
origin: com.owlike/genson

/**
 * @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));
}
origin: com.owlike/genson

@Override
public void serialize(T object, ObjectWriter writer, Context ctx) throws Exception {
 if (object == null) {
  throw new JsonBindingException("Serialization of null primitives is forbidden");
 } else {
  wrapped.serialize(object, writer, ctx);
 }
}
origin: com.owlike/genson

 @Override
 public Converter<?> create(Type type, Genson genson) {
  Converter<?> converter = ThreadLocalHolder.get(CONTEXT_KEY, Converter.class);
  if (converter != null) return converter;
  return delegatedFactory.create(type, genson);
 }
}
origin: owlike/genson

/**
 * 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;
}
origin: com.owlike/genson

public <T> GensonBuilder withDeserializer(Deserializer<T> deserializer,
                     GenericType<? extends T> type) {
 registerDeserializer(deserializer, type.getType());
 return this;
}
origin: owlike/genson

/**
 * 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));
}
origin: owlike/genson

/**
 * 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, GenericType<T> toType) {
 return deserialize(toType, createReader(reader), new Context(this));
}
origin: com.owlike/genson

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);
 }
}
origin: owlike/genson

/**
 * @see #deserializeInto(com.owlike.genson.stream.ObjectReader, Object, Context)
 */
public <T> T deserializeInto(byte[] jsonBytes, T object) {
 return deserializeInto(createReader(jsonBytes), object, new Context(this));
}
origin: com.owlike/genson

/**
 * 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));
}
origin: owlike/genson

/**
 * 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, GenericType<T> toType) {
 return deserialize(toType, createReader(input), new Context(this));
}
origin: owlike/genson

/**
 * @see #deserializeInto(com.owlike.genson.stream.ObjectReader, Object, Context)
 */
public <T> T deserializeInto(InputStream is, T object) {
 return deserializeInto(createReader(is), object, new Context(this));
}
origin: com.owlike/genson

/**
 * 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));
}
origin: com.owlike/genson

/**
 * 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));
}
origin: owlike/genson

/**
 * 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));
}
com.owlike.genson

Most used classes

  • Genson
    Main class of the library. Instances of Genson are thread safe and should be reused. You can instan
  • GensonBuilder
    Use the GensonBuilder class when you want to create a custom Genson instance. This class allows you
  • ObjectReader
    ObjectReader is part of the streaming api, it's implementations allow you to read data from the stre
  • ObjectWriter
    ObjectWriter defines the api allowing to write data to different format and the contract for classes
  • BeanProperty
    Represents a bean property, in practice it can be an object field, method (getter/setter) or constru
  • Context,
  • GenericType,
  • JsonBindingException,
  • HandleBeanView,
  • HandleClassMetadata,
  • JsonProperty,
  • DefaultConverters$HashMapConverter,
  • DefaultConverters$HashTableConverter,
  • DefaultConverters$LinkedHashMapConverter,
  • DefaultConverters$MapConverterFactory,
  • DefaultConverters$PropertiesConverter,
  • DefaultConverters$TreeMapConverter,
  • JAXBBundle,
  • GensonJaxRSFeature
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now