public static String prettyPrint( Object item ) throws IOException { return OBJECT_MAPPER.writer().withDefaultPrettyPrinter().writeValueAsString( item ); } }
public BatchOperations( WebServer webServer ) { this.webServer = webServer; mapper = new ObjectMapper(); }
@Override public AnnotationIntrospector getAnnotationIntrospector() { /* 29-Jul-2009, tatu: it's now possible to disable use of * annotations; can be done using "no-op" introspector */ if (isEnabled(Feature.USE_ANNOTATIONS)) { return super.getAnnotationIntrospector(); } return AnnotationIntrospector.nopInstance(); }
private static String jacksonPrettyPrint( final String json ) throws Exception { Object myObject = MAPPER.readValue( json, Object.class ); return WRITER.writeValueAsString( myObject ); } }
public MappingJsonFactory(ObjectMapper mapper) { super(mapper); if (mapper == null) { setCodec(new ObjectMapper(this)); } }
public static void writeValue( JsonGenerator jgen, Object value ) throws IOException { OBJECT_MAPPER.writeValue( jgen, value ); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified {@link DateFormat}; or, if * null passed, using timestamp (64-bit number. * * @since 1.9 */ public ObjectWriter writer(DateFormat df) { return new ObjectWriter(this, copySerializationConfig().withDateFormat(df)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified JSON View (filter). * * @since 1.9 */ public ObjectWriter writerWithView(Class<?> serializationView) { return new ObjectWriter(this, copySerializationConfig().withView(serializationView)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified filter provider. * * @since 1.9 */ public ObjectWriter writer(FilterProvider filterProvider) { return new ObjectWriter(this, copySerializationConfig().withFilters(filterProvider)); }
/** * Convenience method for creating a new factory instance with additional serializer * provider; equivalent to calling *<pre> * withConfig(getConfig().withAdditionalSerializers(additional)); *<pre> * * @since 1.7 */ public final SerializerFactory withAdditionalSerializers(Serializers additional) { return withConfig(getConfig().withAdditionalSerializers(additional)); }
/** * Convenience method for creating a new factory instance with additional deserializer * provider. * * @since 1.7 */ public final DeserializerFactory withAdditionalDeserializers(Deserializers additional) { return withConfig(getConfig().withAdditionalDeserializers(additional)); }
/** * Convenience method for creating a new factory instance with additional * {@link BeanDeserializerModifier}. * * @since 1.7 */ public final DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier) { return withConfig(getConfig().withDeserializerModifier(modifier)); }
/** * Convenience method for creating a new factory instance with additional * {@link AbstractTypeResolver}. * * @since 1.7 */ public final DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver) { return withConfig(getConfig().withAbstractTypeResolver(resolver)); }
/** * Method called to prepend a reference information in front of * current path */ public void prependPath(Object referrer, String fieldName) { Reference ref = new Reference(referrer, fieldName); prependPath(ref); } /**
/** * Convenience method for constructing {@link ObjectWriter} * with default settings. * * @since 1.6 */ public ObjectWriter writer() { return new ObjectWriter(this, copySerializationConfig()); }
/** * Accessor for getting bean description that only contains class * annotations: useful if no getter/setter/creator information is needed. *<p> * Note: part of {@link MapperConfig} since 1.7 */ @SuppressWarnings("unchecked") @Override public <T extends BeanDescription> T introspectClassAnnotations(JavaType type) { return (T) getClassIntrospector().forClassAnnotations(this, type, this); }
/** * Accessor for getting bean description that only contains class * annotations: useful if no getter/setter/creator information is needed. *<p> * Note: part of {@link MapperConfig} since 1.7 */ @SuppressWarnings("unchecked") @Override public <T extends BeanDescription> T introspectClassAnnotations(JavaType type) { return (T) getClassIntrospector().forClassAnnotations(this, type, this); }
/** * Method that will introspect full bean properties for the purpose * of building a bean deserializer * * @param type Type of class to be introspected */ @SuppressWarnings("unchecked") public <T extends BeanDescription> T introspect(JavaType type) { return (T) getClassIntrospector().forDeserialization(this, type, this); }
/** * Accessor for getting bean description that only contains immediate class * annotations: ones from the class, and its direct mix-in, if any, but * not from super types. *<p> * Note: part of {@link MapperConfig} since 1.7 */ @Override @SuppressWarnings("unchecked") public <T extends BeanDescription> T introspectDirectClassAnnotations(JavaType type) { return (T) getClassIntrospector().forDirectClassAnnotations(this, type, this); }
/** * Factory method for constructing {@link ObjectWriter} that will * pass specific schema object to {@link JsonGenerator} used for * writing content. * * @param schema Schema to pass to generator * * @since 1.9 */ public ObjectWriter writer(FormatSchema schema) { return new ObjectWriter(this, copySerializationConfig(), schema); }