org.codehaus.jackson.annotate.JsonMethod Java Examples

The following examples show how to use org.codehaus.jackson.annotate.JsonMethod. 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: Json.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a Json ObjectMapper that maps fields and optionally pretty prints the
 * serialized objects.
 *
 * @param pretty a flag - if true the output will be pretty printed.
 */
public Json(boolean pretty) {
  myObjectMapper = new ObjectMapper();
  myObjectMapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
  if (pretty) {
    myObjectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
  }
}
 
Example #2
Source File: JsonMarshaller.java    From spring-data-simpledb with MIT License 5 votes vote down vote up
public <T> String marshall(T input) {
	Assert.notNull(input);
	jsonMapper = new ObjectMapper().setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
	jsonMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "@class");
	try {
		return jsonMapper.writeValueAsString(input);
	} catch(Exception e) {
		throw new MappingException(e.getMessage(), e);
	}
}
 
Example #3
Source File: ObjectMapperFactory.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override
public VC withVisibility(JsonMethod method, Visibility v)
{
  return this;
}
 
Example #4
Source File: JsonHelper.java    From gocd-git-path-material-plugin with Apache License 2.0 4 votes vote down vote up
public static String toJson(Object object) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
    return objectMapper.writeValueAsString(object);
}
 
Example #5
Source File: ObjectMapperFactory.java    From attic-apex-core with Apache License 2.0 4 votes vote down vote up
@Override
public VC withVisibility(JsonMethod method, Visibility v)
{
  return this;
}