本文整理汇总了Java中com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion类的典型用法代码示例。如果您正苦于以下问题:Java Inclusion类的具体用法?Java Inclusion怎么用?Java Inclusion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Inclusion类属于com.fasterxml.jackson.databind.annotation.JsonSerialize包,在下文中一共展示了Inclusion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: JsonMapper
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
public JsonMapper(Inclusion inclusion, DateFormat df, boolean replaceNull)
{
mapper = new ObjectMapper();
// 设置输出时包含属性的风格
// mapper.setSerializationInclusion(inclusion);
// // 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
// mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// // 禁止使用int代表Enum的order()來反序列化Enum
// mapper.configure(DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS, true);
// 允许单引号
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
mapper.setDateFormat(df);
if (replaceNull) {
// null 转换为 ""
mapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>()
{
@Override
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException
{
jgen.writeString("");
}
});
}
}
开发者ID:ls960972314,项目名称:report,代码行数:26,代码来源:JsonMapper.java
示例2: getId
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getId() {
if ( id != null ) {
return id;
}
if ( entity != null ) {
id = entity.getUuid();
return id;
}
if ( ( ids != null ) && ( ids.size() > 0 ) ) {
id = ids.get( 0 );
return id;
}
if ( ( entities != null ) && ( entities.size() > 0 ) ) {
entity = entities.get( 0 );
id = entity.getUuid();
return id;
}
if ( ( refs != null ) && ( refs.size() > 0 ) ) {
EntityRef ref = refs.get( 0 );
id = ref.getUuid();
}
return id;
}
开发者ID:apache,项目名称:usergrid,代码行数:25,代码来源:Results.java
示例3: getRef
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
@JsonSerialize(include = Inclusion.NON_NULL)
public EntityRef getRef() {
if ( ref != null ) {
return ref;
}
ref = getEntity();
if ( ref != null ) {
return ref;
}
UUID u = getId();
if ( u != null ) {
String type= null;
if(refs!=null && refs.size()>0){
type = refs.get(0).getType();
}
return ref( type,u );
}
return null;
}
开发者ID:apache,项目名称:usergrid,代码行数:20,代码来源:Results.java
示例4: success
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* 返回日期处理成功结果
* @param data 数据节点对象
* @return JSON结果
*/
public static String success(Object data, String format)
{
Map<String, Object> map = new HashMap<String, Object>();
map.put("code", GlobalResultStatus.SUCCESS.getCode());
if (data != null)
{
map.put("data", data);
}
JsonMapper mapper = new JsonMapper(Inclusion.NON_NULL, new SimpleDateFormat(format));
return mapper.toJson(map);
}
开发者ID:ls960972314,项目名称:report,代码行数:17,代码来源:JsonResult.java
示例5: valueAllowed
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
boolean valueAllowed(Object value, Class cls) {
return value != null
|| (serializerProvider.getConfig() != null
&& serializerProvider.getConfig().getSerializationInclusion() == Include.ALWAYS
&& getAnnotation(cls, JsonSerialize.class) == null)
|| (getAnnotation(cls, JsonSerialize.class) != null
&& readClassAnnotation(cls, JsonSerialize.class, "include") == Inclusion.ALWAYS);
}
开发者ID:monitorjbl,项目名称:json-view,代码行数:9,代码来源:JsonViewSerializer.java
示例6: toJson
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* 将对象转换成json, 可以设置输出属性
*
*
* @param src 对象
* @param inclusion 传入一个枚举值, 设置输出属性
* @return 返回json字符串
*/
public static <T> String toJson(T src, Inclusion inclusion) {
if (src instanceof String) {
return (String) src;
} else {
ObjectMapper customMapper = generateMapper(inclusion);
try {
return customMapper.writeValueAsString(src);
} catch (JsonProcessingException e) {
LOG.error("JsonProcessingException: ", e);
}
}
return null;
}
开发者ID:uncodecn,项目名称:uncode-dal-all,代码行数:22,代码来源:JsonUtils.java
示例7: generateMapper
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* 通过Inclusion创建ObjectMapper对象
*
*
* @param inclusion 传入一个枚举值, 设置输出属性
* @return 返回ObjectMapper对象
*/
private static ObjectMapper generateMapper(Inclusion inclusion) {
ObjectMapper customMapper = new ObjectMapper();
// 所有日期格式都统一为以下样式
customMapper.setDateFormat(new SimpleDateFormat(DATE_TIME_FORMAT));
return customMapper;
}
开发者ID:uncodecn,项目名称:uncode-dal-all,代码行数:16,代码来源:JsonUtils.java
示例8: getEntity
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
@JsonSerialize(include = Inclusion.NON_NULL)
public Entity getEntity() {
mergeEntitiesWithMetadata();
if ( entity != null ) {
return entity;
}
if ( ( entities != null ) && ( entities.size() > 0 ) ) {
entity = entities.get( 0 );
return entity;
}
return null;
}
开发者ID:apache,项目名称:usergrid,代码行数:13,代码来源:Results.java
示例9: getEntitiesMap
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
@JsonSerialize(include = Inclusion.NON_NULL)
public Map<UUID, Entity> getEntitiesMap() {
if ( entitiesMap != null ) {
return entitiesMap;
}
if ( getEntities() != null ) {
entitiesMap = new LinkedHashMap<UUID, Entity>();
for ( Entity entity : getEntities() ) {
entitiesMap.put( entity.getUuid(), entity );
}
}
return entitiesMap;
}
开发者ID:apache,项目名称:usergrid,代码行数:14,代码来源:Results.java
示例10: buildNormalMapper
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* 创建输出全部属性到Json字符串的Mapper.
*/
public static JsonMapper buildNormalMapper()
{
return new JsonMapper(Inclusion.ALWAYS);
}
开发者ID:ls960972314,项目名称:report,代码行数:8,代码来源:JsonMapper.java
示例11: buildNonNullMapper
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* 创建只输出非空属性到Json字符串的Mapper.
*/
public static JsonMapper buildNonNullMapper()
{
return new JsonMapper(Inclusion.NON_NULL);
}
开发者ID:ls960972314,项目名称:report,代码行数:8,代码来源:JsonMapper.java
示例12: buildNonDefaultMapper
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* 创建只输出初始值被改变的属性到Json字符串的Mapper.
*/
public static JsonMapper buildNonDefaultMapper()
{
return new JsonMapper(Inclusion.NON_DEFAULT);
}
开发者ID:ls960972314,项目名称:report,代码行数:8,代码来源:JsonMapper.java
示例13: buildNonEmptyMapper
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* 创建只输出非Null且非Empty(如List.isEmpty)的属性到Json字符串的Mapper.
*/
public static JsonMapper buildNonEmptyMapper()
{
return new JsonMapper(Inclusion.NON_EMPTY);
}
开发者ID:ls960972314,项目名称:report,代码行数:8,代码来源:JsonMapper.java
示例14: reportSuccess
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* 报表返回格式日期处理成功结果
* @param data 数据节点对象
* @return JSON结果
*/
public static String reportSuccess(Object data, String format)
{
JsonMapper mapper = new JsonMapper(Inclusion.NON_NULL, new SimpleDateFormat(format));
return mapper.toJson(data);
}
开发者ID:ls960972314,项目名称:report,代码行数:11,代码来源:JsonResult.java
示例15: getAccessToken
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* Returns the OAuth token that was sent with the request
*
* @return the OAuth token
*/
@JsonProperty("access_token")
@JsonSerialize(include = Inclusion.NON_NULL)
public String getAccessToken() {
return accessToken;
}
开发者ID:ablozhou,项目名称:usergrid_android_sdk,代码行数:11,代码来源:ApiResponse.java
示例16: getErrorDescription
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* Returns the 'error_description' property of the response.
*
* @return the error description
*/
@JsonSerialize(include = Inclusion.NON_NULL)
@JsonProperty("error_description")
public String getErrorDescription() {
return errorDescription;
}
开发者ID:ablozhou,项目名称:usergrid_android_sdk,代码行数:11,代码来源:ApiResponse.java
示例17: getErrorUri
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
* Returns the 'error_uri' property of the response.
*
* @return the error URI
*/
@JsonSerialize(include = Inclusion.NON_NULL)
@JsonProperty("error_uri")
public String getErrorUri() {
return errorUri;
}
开发者ID:ablozhou,项目名称:usergrid_android_sdk,代码行数:11,代码来源:ApiResponse.java
示例18: getLast
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getLast() {
return last;
}
开发者ID:ablozhou,项目名称:usergrid_android_sdk,代码行数:5,代码来源:ApiResponse.java
示例19: getUser
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getUser() {
return user;
}
开发者ID:ablozhou,项目名称:usergrid_android_sdk,代码行数:5,代码来源:AggregateCounterSet.java
示例20: getGroup
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; //导入依赖的package包/类
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getGroup() {
return group;
}
开发者ID:ablozhou,项目名称:usergrid_android_sdk,代码行数:5,代码来源:AggregateCounterSet.java
注:本文中的com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论