Java Code Examples for com.fasterxml.jackson.core.JsonGenerator#Feature

The following examples show how to use com.fasterxml.jackson.core.JsonGenerator#Feature . 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: Jackson2ObjectMapperBuilder.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) {
	if (feature instanceof JsonParser.Feature) {
		objectMapper.configure((JsonParser.Feature) feature, enabled);
	}
	else if (feature instanceof JsonGenerator.Feature) {
		objectMapper.configure((JsonGenerator.Feature) feature, enabled);
	}
	else if (feature instanceof SerializationFeature) {
		objectMapper.configure((SerializationFeature) feature, enabled);
	}
	else if (feature instanceof DeserializationFeature) {
		objectMapper.configure((DeserializationFeature) feature, enabled);
	}
	else if (feature instanceof MapperFeature) {
		objectMapper.configure((MapperFeature) feature, enabled);
	}
	else {
		throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName());
	}
}
 
Example 2
Source File: Jackson2ObjectMapperBuilder.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) {
	if (feature instanceof JsonParser.Feature) {
		objectMapper.configure((JsonParser.Feature) feature, enabled);
	}
	else if (feature instanceof JsonGenerator.Feature) {
		objectMapper.configure((JsonGenerator.Feature) feature, enabled);
	}
	else if (feature instanceof SerializationFeature) {
		objectMapper.configure((SerializationFeature) feature, enabled);
	}
	else if (feature instanceof DeserializationFeature) {
		objectMapper.configure((DeserializationFeature) feature, enabled);
	}
	else if (feature instanceof MapperFeature) {
		objectMapper.configure((MapperFeature) feature, enabled);
	}
	else {
		throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName());
	}
}
 
Example 3
Source File: MapperBuilder.java    From qconfig with MIT License 6 votes vote down vote up
private static void configure(ObjectMapper om, Object feature, boolean state) {
    if (feature instanceof SerializationFeature)
        om.configure((SerializationFeature) feature, state);
    else if (feature instanceof DeserializationFeature)
        om.configure((DeserializationFeature) feature, state);
    else if (feature instanceof JsonParser.Feature)
        om.configure((JsonParser.Feature) feature, state);
    else if (feature instanceof JsonGenerator.Feature)
        om.configure((JsonGenerator.Feature) feature, state);
    else if (feature instanceof MapperFeature)
        om.configure((MapperFeature) feature, state);
    else if (feature instanceof Include) {
        if (state) {
            om.setSerializationInclusion((Include) feature);
        }
    }
}
 
Example 4
Source File: Jackson2ObjectMapperBuilder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) {
	if (feature instanceof JsonParser.Feature) {
		objectMapper.configure((JsonParser.Feature) feature, enabled);
	}
	else if (feature instanceof JsonGenerator.Feature) {
		objectMapper.configure((JsonGenerator.Feature) feature, enabled);
	}
	else if (feature instanceof SerializationFeature) {
		objectMapper.configure((SerializationFeature) feature, enabled);
	}
	else if (feature instanceof DeserializationFeature) {
		objectMapper.configure((DeserializationFeature) feature, enabled);
	}
	else if (feature instanceof MapperFeature) {
		objectMapper.configure((MapperFeature) feature, enabled);
	}
	else {
		throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName());
	}
}
 
Example 5
Source File: Jackson2ObjectMapperBuilder.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) {
	if (feature instanceof JsonParser.Feature) {
		objectMapper.configure((JsonParser.Feature) feature, enabled);
	}
	else if (feature instanceof JsonGenerator.Feature) {
		objectMapper.configure((JsonGenerator.Feature) feature, enabled);
	}
	else if (feature instanceof SerializationFeature) {
		objectMapper.configure((SerializationFeature) feature, enabled);
	}
	else if (feature instanceof DeserializationFeature) {
		objectMapper.configure((DeserializationFeature) feature, enabled);
	}
	else if (feature instanceof MapperFeature) {
		objectMapper.configure((MapperFeature) feature, enabled);
	}
	else {
		throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName());
	}
}
 
Example 6
Source File: MapperBuilder.java    From codehelper.generator with Apache License 2.0 6 votes vote down vote up
private static void configure(ObjectMapper om, Object feature, boolean state) {
    if (feature instanceof SerializationFeature)
        om.configure((SerializationFeature) feature, state);
    else if (feature instanceof DeserializationFeature)
        om.configure((DeserializationFeature) feature, state);
    else if (feature instanceof JsonParser.Feature)
        om.configure((JsonParser.Feature) feature, state);
    else if (feature instanceof JsonGenerator.Feature)
        om.configure((JsonGenerator.Feature) feature, state);
    else if (feature instanceof MapperFeature)
        om.configure((MapperFeature) feature, state);
    else if (feature instanceof Include) {
        if (state) {
            om.setSerializationInclusion((Include) feature);
        }
    }
}
 
Example 7
Source File: JacksonDsl.java    From spring-fu with Apache License 2.0 4 votes vote down vote up
/**
 * Enable generator feature
 */
public JacksonDsl enableGeneratorFeature(JsonGenerator.Feature feature) {
	this.properties.getGenerator().put(feature, true);
	return this;
}
 
Example 8
Source File: JacksonDsl.java    From spring-fu with Apache License 2.0 4 votes vote down vote up
/**
 * Disable generator feature
 */
public JacksonDsl disableGeneratorFeature(JsonGenerator.Feature feature) {
	properties.getGenerator().put(feature, false);
	return this;
}
 
Example 9
Source File: JsonXContentGenerator.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(JsonGenerator.Feature f, boolean state) {
    generator.configure(f, state);
}
 
Example 10
Source File: JsonXContentGenerator.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isEnabled(JsonGenerator.Feature f) {
    return generator.isEnabled(f);
}
 
Example 11
Source File: StreamingObjectMapper.java    From nexus-public with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Decorator method to {@link ObjectMapper#disable(Feature...)}
 *
 * return StreamingObjectMapper for chaining.
 */
public StreamingObjectMapper disable(final JsonGenerator.Feature... feature) {
  objectMapper.disable(feature);
  return this;
}
 
Example 12
Source File: XContentGenerator.java    From crate with Apache License 2.0 votes vote down vote up
void configure(JsonGenerator.Feature f, boolean state); 
Example 13
Source File: XContentGenerator.java    From crate with Apache License 2.0 votes vote down vote up
boolean isEnabled(JsonGenerator.Feature f);