Java Code Examples for com.fasterxml.jackson.annotation.JsonInclude.Include#NON_DEFAULT
The following examples show how to use
com.fasterxml.jackson.annotation.JsonInclude.Include#NON_DEFAULT .
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: JsonMapper.java From lightconf with GNU General Public License v3.0 | 5 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { if (mapper == null) { mapper = new JsonMapper(Include.NON_DEFAULT); } return mapper; }
Example 2
Source File: JsonMapper.java From Shop-for-JavaWeb with MIT License | 5 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { if (mapper == null){ mapper = new JsonMapper(Include.NON_DEFAULT); } return mapper; }
Example 3
Source File: JsonMapper.java From LDMS with Apache License 2.0 | 5 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { if (jsonMapper == null){ jsonMapper = new JsonMapper(Include.NON_DEFAULT); } return jsonMapper; }
Example 4
Source File: JsonMapper.java From azeroth with Apache License 2.0 | 4 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { return new JsonMapper(Include.NON_DEFAULT); }
Example 5
Source File: JsonMapper.java From springcloud-idempotent-starter with GNU General Public License v3.0 | 4 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { return new JsonMapper(Include.NON_DEFAULT); }
Example 6
Source File: JsonMapper.java From wish-pay with Apache License 2.0 | 4 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { return new JsonMapper(Include.NON_DEFAULT); }
Example 7
Source File: JsonMapper.java From jeesuite-libs with Apache License 2.0 | 4 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { return new JsonMapper(Include.NON_DEFAULT); }
Example 8
Source File: JsonMapper.java From spring-boot-quickstart with Apache License 2.0 | 4 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { return new JsonMapper(Include.NON_DEFAULT); }
Example 9
Source File: MessageSerializer.java From jackson-datatype-protobuf with Apache License 2.0 | 4 votes |
@Override public void serialize( MessageOrBuilder message, JsonGenerator generator, SerializerProvider serializerProvider ) throws IOException { generator.writeStartObject(); boolean proto3 = message.getDescriptorForType().getFile().getSyntax() == Syntax.PROTO3; Include include = serializerProvider.getConfig().getDefaultPropertyInclusion().getValueInclusion(); boolean writeDefaultValues = proto3 && include != Include.NON_DEFAULT; boolean writeEmptyCollections = include != Include.NON_DEFAULT && include != Include.NON_EMPTY; PropertyNamingStrategyBase namingStrategy = new PropertyNamingStrategyWrapper(serializerProvider.getConfig().getPropertyNamingStrategy()); Descriptor descriptor = message.getDescriptorForType(); List<FieldDescriptor> fields = new ArrayList<>(descriptor.getFields()); if (message instanceof ExtendableMessageOrBuilder<?>) { for (ExtensionInfo extensionInfo : config.extensionRegistry().getExtensionsByDescriptor(descriptor)) { fields.add(extensionInfo.descriptor); } } for (FieldDescriptor field : fields) { if (field.isRepeated()) { List<?> valueList = (List<?>) message.getField(field); if (!valueList.isEmpty() || writeEmptyCollections) { if (field.isMapField()) { generator.writeFieldName(namingStrategy.translate(field.getName())); writeMap(field, valueList, generator, serializerProvider); } else if (valueList.size() == 1 && writeSingleElementArraysUnwrapped(serializerProvider)) { generator.writeFieldName(namingStrategy.translate(field.getName())); writeValue(field, valueList.get(0), generator, serializerProvider); } else { generator.writeArrayFieldStart(namingStrategy.translate(field.getName())); for (Object subValue : valueList) { writeValue(field, subValue, generator, serializerProvider); } generator.writeEndArray(); } } } else if (message.hasField(field) || (writeDefaultValues && !supportsFieldPresence(field) && field.getContainingOneof() == null)) { generator.writeFieldName(namingStrategy.translate(field.getName())); writeValue(field, message.getField(field), generator, serializerProvider); } else if (include == Include.ALWAYS && field.getContainingOneof() == null) { generator.writeFieldName(namingStrategy.translate(field.getName())); generator.writeNull(); } } generator.writeEndObject(); }
Example 10
Source File: JsonMapper.java From dubai with MIT License | 4 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 */ public static JsonMapper nonDefaultMapper() { return new JsonMapper(Include.NON_DEFAULT); }
Example 11
Source File: JacksonBundle.java From base-framework with Apache License 2.0 | 2 votes |
/** * 创建只输出初始值被改变的属性到Json字符串的ObjectMapper, 最节约的存储方式。 * @return */ public static JacksonBundle nonDefaultMapper() { return new JacksonBundle(Include.NON_DEFAULT); }