Java Code Examples for org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#defaultViewInclusion()

The following examples show how to use org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#defaultViewInclusion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainController.java    From steady with Apache License 2.0 6 votes vote down vote up
/**
	 * Can be used to do some initialization at application startup, but does not do anything right now.
	 *
	 * @return a {@link org.springframework.http.converter.json.Jackson2ObjectMapperBuilder} object.
	 */
//	@Bean
//	CommandLineRunner init() { return null; }
//
	@Bean
	public Jackson2ObjectMapperBuilder jacksonBuilder() {
		final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();

		builder.defaultViewInclusion(true);
		//builder.indentOutput(true).dateFormat(new SimpleDateFormat("yyyy-MM-dd"));

		// Custom serializers
		Map<Class<?>,JsonSerializer<?>> custom_serializers = new HashMap<Class<?>,JsonSerializer<?>>();
		custom_serializers.put(ASTSignatureChange.class, new ASTSignatureChangeSerializer());
		custom_serializers.put(ASTConstructBodySignature.class, new ASTConstructBodySignatureSerializer());
		custom_serializers.put(PythonConstructDigest.class, new PythonConstructDigestSerializer());
		builder.serializersByType(custom_serializers);

		// Custom de-serializers
		Map<Class<?>,JsonDeserializer<?>> custom_deserializers = new HashMap<Class<?>,JsonDeserializer<?>>();
		custom_deserializers.put(ASTConstructBodySignature.class, new ASTConstructBodySignatureDeserializer());
		builder.deserializersByType(custom_deserializers);

		return builder;
	}
 
Example 2
Source File: MainController.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
	 * Can be used to do some initialization at application startup, but does not do anything right now.
	 *
	 * @return a {@link org.springframework.http.converter.json.Jackson2ObjectMapperBuilder} object.
	 */
//	@Bean
//	CommandLineRunner init() { return null; }

	@Bean
	public Jackson2ObjectMapperBuilder jacksonBuilder() {
	    Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
	    builder.defaultViewInclusion(true);
	    //builder.indentOutput(true).dateFormat(new SimpleDateFormat("yyyy-MM-dd"));
	    return builder;
	}