@Override public Object findSerializer(Annotated a) { /* 21-May-2009, tatu: Slight change; primary annotation is now * @JsonSerialize; @JsonUseSerializer is deprecated */ JsonSerialize ann = a.getAnnotation(JsonSerialize.class); if (ann != null) { Class<? extends JsonSerializer<?>> serClass = ann.using(); if (serClass != JsonSerializer.None.class) { return serClass; } } /* 18-Oct-2010, tatu: [JACKSON-351] @JsonRawValue handled just here, for now; * if we need to get raw indicator from other sources need to add * separate accessor within {@link AnnotationIntrospector} interface. */ JsonRawValue annRaw = a.getAnnotation(JsonRawValue.class); if ((annRaw != null) && annRaw.value()) { // let's construct instance with nominal type: Class<?> cls = a.getRawType(); return new RawSerializer<Object>(cls); } return null; }
@Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { // type not really known, but since it is a JSON string: return createSchemaNode("string", true); } }
@Override public void serializeWithType(T value, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException { typeSer.writeTypePrefixForScalar(value, jgen); serialize(value, jgen, provider); typeSer.writeTypeSuffixForScalar(value, jgen); }
@Override public Object findSerializer(Annotated a) { /* 21-May-2009, tatu: Slight change; primary annotation is now * @JsonSerialize; @JsonUseSerializer is deprecated */ JsonSerialize ann = a.getAnnotation(JsonSerialize.class); if (ann != null) { Class<? extends JsonSerializer<?>> serClass = ann.using(); if (serClass != JsonSerializer.None.class) { return serClass; } } /* 18-Oct-2010, tatu: [JACKSON-351] @JsonRawValue handled just here, for now; * if we need to get raw indicator from other sources need to add * separate accessor within {@link AnnotationIntrospector} interface. */ JsonRawValue annRaw = a.getAnnotation(JsonRawValue.class); if ((annRaw != null) && annRaw.value()) { // let's construct instance with nominal type: Class<?> cls = a.getRawType(); return new RawSerializer<Object>(cls); } return null; }
@Override public void serializeWithType(T value, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException { typeSer.writeTypePrefixForScalar(value, jgen); serialize(value, jgen, provider); typeSer.writeTypeSuffixForScalar(value, jgen); }
@Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { // type not really known, but since it is a JSON string: return createSchemaNode("string", true); } }
/** * <p>Constructor for JacksonObjectMapperProvider.</p> */ public JacksonObjectMapperProvider() { this.objectMapper = new ObjectMapper(); objectMapper.configure(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS, true); objectMapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); module.addSerializer(ObjectMapperString.class, new RawSerializer<>(Object.class)); module.addSerializer(JSONObject.class, new RawSerializer<>(Object.class)); module.addSerializer(JSONArray.class, new RawSerializer<>(Object.class)); objectMapper.registerModule(module); }
@Override public void serializeWithType(T value, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException { typeSer.writeTypePrefixForScalar(value, jgen); serialize(value, jgen, provider); typeSer.writeTypeSuffixForScalar(value, jgen); }
@Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { // type not really known, but since it is a JSON string: return createSchemaNode("string", true); } }
@Override public Object findSerializer(Annotated a) { /* 21-May-2009, tatu: Slight change; primary annotation is now * @JsonSerialize; @JsonUseSerializer is deprecated */ JsonSerialize ann = a.getAnnotation(JsonSerialize.class); if (ann != null) { Class<? extends JsonSerializer<?>> serClass = ann.using(); if (serClass != JsonSerializer.None.class) { return serClass; } } /* 18-Oct-2010, tatu: [JACKSON-351] @JsonRawValue handled just here, for now; * if we need to get raw indicator from other sources need to add * separate accessor within {@link AnnotationIntrospector} interface. */ JsonRawValue annRaw = a.getAnnotation(JsonRawValue.class); if ((annRaw != null) && annRaw.value()) { // let's construct instance with nominal type: Class<?> cls = a.getRawType(); return new RawSerializer<Object>(cls); } return null; }
@Override public void serializeWithType(T value, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException { typeSer.writeTypePrefixForScalar(value, jgen); serialize(value, jgen, provider); typeSer.writeTypeSuffixForScalar(value, jgen); }
@Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { // type not really known, but since it is a JSON string: return createSchemaNode("string", true); } }
@Override public Object findSerializer(Annotated a) { /* 21-May-2009, tatu: Slight change; primary annotation is now * @JsonSerialize; @JsonUseSerializer is deprecated */ JsonSerialize ann = a.getAnnotation(JsonSerialize.class); if (ann != null) { Class<? extends JsonSerializer<?>> serClass = ann.using(); if (serClass != JsonSerializer.None.class) { return serClass; } } /* 18-Oct-2010, tatu: [JACKSON-351] @JsonRawValue handled just here, for now; * if we need to get raw indicator from other sources need to add * separate accessor within {@link AnnotationIntrospector} interface. */ JsonRawValue annRaw = a.getAnnotation(JsonRawValue.class); if ((annRaw != null) && annRaw.value()) { // let's construct instance with nominal type: Class<?> cls = a.getRawType(); return new RawSerializer<Object>(cls); } return null; }