Java 类org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion 实例源码

项目:urule    文件:WriteJsonServletHandler.java   
protected void writeObjectToJson(HttpServletResponse resp,Object obj) throws ServletException, IOException{
    resp.setHeader("Access-Control-Allow-Origin", "*");
    resp.setContentType("text/json");
    resp.setCharacterEncoding("UTF-8");
    ObjectMapper mapper=new ObjectMapper();
    mapper.setSerializationInclusion(Inclusion.NON_NULL);
    mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false);
    mapper.setDateFormat(new SimpleDateFormat(Configure.getDateFormat()));
    OutputStream out = resp.getOutputStream();
    try {
        mapper.writeValue(out, obj);
    } finally {
        out.flush();
        out.close();
    }
}
项目:uflo    文件:WriteJsonServletHandler.java   
protected void writeObjectToJson(HttpServletResponse resp,Object obj) throws ServletException, IOException{
    resp.setHeader("Access-Control-Allow-Origin", "*");
    resp.setContentType("text/json");
    resp.setCharacterEncoding("UTF-8");
    ObjectMapper mapper=new ObjectMapper();
    mapper.setSerializationInclusion(Inclusion.NON_NULL);
    mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false);
    mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
    OutputStream out = resp.getOutputStream();
    try {
        mapper.writeValue(out, obj);
    } finally {
        out.flush();
        out.close();
    }
}
项目:amalia-model    文件:JsonModelSerializer.java   
public JsonModelSerializer(boolean doNullValues, Class<T> serializedType) {
        super();
        objectMapper = new ObjectMapper();
        AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
        // make serializer use JAXB annotations (only)
        SerializationConfig sc = objectMapper.getSerializationConfig().withAnnotationIntrospector(introspector);
        sc.with(SerializationConfig.Feature.INDENT_OUTPUT);

        if (!doNullValues) {
            sc.without(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES);
            sc.without(SerializationConfig.Feature.WRITE_EMPTY_JSON_ARRAYS);
            sc = sc.withSerializationInclusion(Inclusion.NON_EMPTY);
        }

        objectMapper.setSerializationConfig(sc);
//      if (!doNullValues) {
//          objectMapper.setSerializationInclusion(Inclusion.NON_EMPTY);
//      }
    }
项目:onboard    文件:RedisPublisher.java   
private void broadcastByActivity(User owner, Activity activity, BaseProjectItem originalItem, BaseProjectItem updatedItem)
        throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
    ObjectWriter ow = objectMapper.writer().withDefaultPrettyPrinter();
    activity.setSubscribers(userService.getUserByProjectId(activity.getProjectId()));
    activity.setAttachObject((BaseProjectItem)identifiableManager.getIdentifiableByTypeAndId(activity.getAttachType(),
            activity.getAttachId()));
    String message = "";
    try {
        message = ow.writeValueAsString(activity);
    } catch (IOException e) {
        e.printStackTrace();
    }
    template.convertAndSend("channel", message);
}
项目:gae-jersey-guice-jsf    文件:Jackson1.java   
public static ObjectMapper createFieldsMapper()
    {
        ObjectMapper mapper = new ObjectMapper();

        // limit to fields only
        mapper.enable(SerializationConfig.Feature.AUTO_DETECT_FIELDS);
        mapper.enable(DeserializationConfig.Feature.AUTO_DETECT_FIELDS);
        mapper.disable(SerializationConfig.Feature.AUTO_DETECT_GETTERS);
        mapper.disable(SerializationConfig.Feature.AUTO_DETECT_IS_GETTERS);
        mapper.disable(DeserializationConfig.Feature.AUTO_DETECT_SETTERS);
        mapper.disable(DeserializationConfig.Feature.AUTO_DETECT_CREATORS);

        // general configuration
        mapper.setSerializationInclusion(Inclusion.NON_NULL);
        mapper.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
//      json.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);

        return mapper;
    }
项目:gae-jersey-guice-jsf    文件:Jackson1.java   
public static ObjectMapper createPropsMapper()
    {
        ObjectMapper mapper = new ObjectMapper();

        // limit to properties only
        mapper.disable(SerializationConfig.Feature.AUTO_DETECT_FIELDS);
        mapper.enable(SerializationConfig.Feature.AUTO_DETECT_GETTERS);
        mapper.enable(SerializationConfig.Feature.AUTO_DETECT_IS_GETTERS);
        mapper.disable(DeserializationConfig.Feature.AUTO_DETECT_FIELDS);
        mapper.enable(DeserializationConfig.Feature.AUTO_DETECT_SETTERS);
        mapper.enable(DeserializationConfig.Feature.AUTO_DETECT_CREATORS);

        // general configuration
        mapper.setSerializationInclusion(Inclusion.NON_NULL);
        mapper.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
//      json.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);

        return mapper;
    }
项目:12306-android-Decompile    文件:SerializationConfig.java   
public void fromAnnotations(Class<?> paramClass)
{
  AnnotationIntrospector localAnnotationIntrospector = getAnnotationIntrospector();
  AnnotatedClass localAnnotatedClass = AnnotatedClass.construct(paramClass, localAnnotationIntrospector, null);
  this._base = this._base.withVisibilityChecker(localAnnotationIntrospector.findAutoDetectVisibility(localAnnotatedClass, getDefaultVisibilityChecker()));
  JsonSerialize.Inclusion localInclusion = localAnnotationIntrospector.findSerializationInclusion(localAnnotatedClass, null);
  if (localInclusion != this._serializationInclusion)
    setSerializationInclusion(localInclusion);
  JsonSerialize.Typing localTyping = localAnnotationIntrospector.findSerializationTyping(localAnnotatedClass);
  Feature localFeature;
  if (localTyping != null)
  {
    localFeature = Feature.USE_STATIC_TYPING;
    if (localTyping != JsonSerialize.Typing.STATIC)
      break label92;
  }
  label92: for (boolean bool = true; ; bool = false)
  {
    set(localFeature, bool);
    return;
  }
}
项目:lens    文件:BaseLensCommand.java   
/**
 * Instantiates a new base lens command.
 */
public BaseLensCommand() {
  mapper = new ObjectMapper();
  mapper.setSerializationInclusion(Inclusion.NON_NULL);
  mapper.setSerializationInclusion(Inclusion.NON_DEFAULT);
  pp = new DefaultPrettyPrinter();
  pp.indentObjectsWith(new Indenter() {
    @Override
    public void writeIndentation(JsonGenerator jg, int level) throws IOException {
      jg.writeRaw("\n");
      for (int i = 0; i < level; i++) {
        jg.writeRaw(" ");
      }
    }

    @Override
    public boolean isInline() {
      return false;
    }
  });
}
项目:pinot    文件:StarTreeIndexViewer.java   
public StarTreeIndexViewer(File segmentDir) throws Exception {
  IndexSegment indexSegment = Loaders.IndexSegment.load(segmentDir, ReadMode.heap);

  dictionaries = new HashMap<String, Dictionary>();
  valueIterators = new HashMap<String, BlockSingleValIterator>();
  SegmentMetadataImpl metadata = new SegmentMetadataImpl(segmentDir);

  for (String columnName : metadata.getAllColumns()) {
    DataSource dataSource = indexSegment.getDataSource(columnName);
    Block block = dataSource.nextBlock();
    BlockValSet blockValSet = block.getBlockValueSet();
    BlockSingleValIterator itr = (BlockSingleValIterator) blockValSet.iterator();
    valueIterators.put(columnName, itr);
    dictionaries.put(columnName, dataSource.getDictionary());
  }
  File starTreeFile = SegmentDirectoryPaths.findStarTreeFile(segmentDir);
  StarTree tree = new OffHeapStarTree(starTreeFile, ReadMode.mmap);
  _dimensionNames = tree.getDimensionNames();
  StarTreeJsonNode jsonRoot = new StarTreeJsonNode("ROOT");
  build(tree.getRoot(), jsonRoot);
  ObjectMapper objectMapper = new ObjectMapper();
  objectMapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_NULL);
  String writeValueAsString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonRoot);
  LOGGER.info(writeValueAsString);
  startServer(segmentDir, writeValueAsString);
}
项目:RHome    文件:SerializationConfig.java   
/**
 * Method that checks class annotations that the argument Object has,
 * and modifies settings of this configuration object accordingly,
 * similar to how those annotations would affect actual value classes
 * annotated with them, but with global scope. Note that not all
 * annotations have global significance, and thus only subset of
 * Jackson annotations will have any effect.
 *<p>
 * Serialization annotations that are known to have effect are:
 *<ul>
 * <li>{@link JsonWriteNullProperties}</li>
 * <li>{@link JsonAutoDetect}</li>
 * <li>{@link JsonSerialize#typing}</li>
 *</ul>
 * 
 * @param cls Class of which class annotations to use
 *   for changing configuration settings
 */
//@Override
public void fromAnnotations(Class<?> cls)
{
    /* 10-Jul-2009, tatu: Should be able to just pass null as
     *    'MixInResolver'; no mix-ins set at this point
     * 29-Jul-2009, tatu: Also, we do NOT ignore annotations here, even
     *    if Feature.USE_ANNOTATIONS was disabled, since caller
     *    specifically requested annotations to be added with this call
     */
    AnnotatedClass ac = AnnotatedClass.construct(cls, _annotationIntrospector, null);
    _visibilityChecker = _annotationIntrospector.findAutoDetectVisibility(ac, _visibilityChecker);

    // How about writing null property values?
    JsonSerialize.Inclusion incl = _annotationIntrospector.findSerializationInclusion(ac, null);
    if (incl != _serializationInclusion) {
        setSerializationInclusion(incl);
    }

    JsonSerialize.Typing typing = _annotationIntrospector.findSerializationTyping(ac);
    if (typing != null) {
        set(Feature.USE_STATIC_TYPING, (typing == JsonSerialize.Typing.STATIC));
    }
}
项目:projectforge-webapp    文件:Json.java   
public static String toJson(Object object) {
    ObjectMapper mapper = new ObjectMapper(new MyJsonFactory());
    SimpleModule module = new SimpleModule("fullcalendar", new Version(1, 0, 0, null));
    module.addSerializer(new DateTimeSerializer());
    module.addSerializer(new LocalTimeSerializer());
    mapper.registerModule(module);
    mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);

    String json = null;
    try {
        json = mapper.writeValueAsString(object);
    } catch (Exception e) {
        throw new RuntimeException("Error encoding object: " + object + " into JSON string", e);
    }
    return json;
}
项目:12306-android-Decompile    文件:SerializationConfig.java   
public void fromAnnotations(Class<?> paramClass)
{
  AnnotationIntrospector localAnnotationIntrospector = getAnnotationIntrospector();
  AnnotatedClass localAnnotatedClass = AnnotatedClass.construct(paramClass, localAnnotationIntrospector, null);
  this._base = this._base.withVisibilityChecker(localAnnotationIntrospector.findAutoDetectVisibility(localAnnotatedClass, getDefaultVisibilityChecker()));
  JsonSerialize.Inclusion localInclusion = localAnnotationIntrospector.findSerializationInclusion(localAnnotatedClass, null);
  if (localInclusion != this._serializationInclusion)
    setSerializationInclusion(localInclusion);
  JsonSerialize.Typing localTyping = localAnnotationIntrospector.findSerializationTyping(localAnnotatedClass);
  Feature localFeature;
  if (localTyping != null)
  {
    localFeature = Feature.USE_STATIC_TYPING;
    if (localTyping != JsonSerialize.Typing.STATIC)
      break label92;
  }
  label92: for (boolean bool = true; ; bool = false)
  {
    set(localFeature, bool);
    return;
  }
}
项目:elasterix    文件:ApiHttpMessage.java   
@JsonCreator
protected ApiHttpMessage(@JsonProperty("httpRequest") HttpRequest httpRequest,
                         @JsonProperty("version") String version,
                         @JsonProperty("domain") String domain,
                         @JsonProperty("actorId") String actorId,
                         @JsonProperty("action") String action) {
    this.httpRequest = httpRequest;
    this.actorId = actorId;
    this.domain = domain;
    this.version = version;
    this.action = action;

    // init object mapper
    objectMapper = new ObjectMapper();
    //objectMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
    objectMapper.setSerializationInclusion(Inclusion.NON_NULL);
}
项目:orion-jclouds    文件:OrionCustomModule.java   
@Provides
public ObjectMapper getObjectMapper() {
    // configure objectmapper and provide it
    SimpleModule module = new SimpleModule("SimpleAbstractTypeResolver", Version.unknownVersion());
    module.addAbstractTypeMapping(MutableBlobProperties.class, MutableBlobPropertiesImpl.class);
    module.addAbstractTypeMapping(MutableContentMetadata.class, BaseMutableContentMetadata.class);
    module.addAbstractTypeMapping(OrionSpecificFileMetadata.class, OrionSpecificFileMetadataImpl.class);
    module.addAbstractTypeMapping(Attributes.class, AttributesImpl.class);
    module.addAbstractTypeMapping(OrionError.class, OrionErrorImpl.class);
    module.addAbstractTypeMapping(OrionChildMetadata.class, OrionChildMetadataImpl.class);
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(module);
    mapper.setSerializationInclusion(Inclusion.NON_NULL);
    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    return mapper;
}
项目:cwierkacz    文件:TwitterAccountDaoTest.java   
@Test
public void simpleTest( ) throws JsonGenerationException, JsonMappingException, IOException {
    UserDao userDao = new UserDao();
    userDao.setName("sss");

    TwitterAccountDao accountDao = new TwitterAccountDao();
    accountDao.setAccessToken("1234");
    accountDao.setAccessTokenSecret("456");
    accountDao.setAccountName("test");
    accountDao.setDeleted(false);
    accountDao.setExternalId(1l);
    accountDao.setId(1l);

    userDao.setAccounts(new HashSet<>(Arrays.asList(accountDao)));
    accountDao.addUser(userDao);

    ObjectMapper objectMapper = new ObjectMapper();

    objectMapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_NULL);
    String result = objectMapper.writeValueAsString(userDao);
}
项目:urule    文件:PackageServletHandler.java   
public void pushKnowledgePackageToClients(HttpServletRequest req, HttpServletResponse resp) throws Exception {
    String project=req.getParameter("project");
    project=Utils.decodeURL(project);
    String packageId=project+"/"+Utils.decodeURL(req.getParameter("packageId"));
    if(packageId.startsWith("/")){
        packageId=packageId.substring(1,packageId.length());
    }
    KnowledgePackage knowledgePackage=CacheUtils.getKnowledgeCache().getKnowledge(packageId);

    ObjectMapper mapper=new ObjectMapper();
    mapper.setSerializationInclusion(Inclusion.NON_NULL);
    mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false);
    mapper.setDateFormat(new SimpleDateFormat(Configure.getDateFormat()));
    StringWriter writer=new StringWriter();
    mapper.writeValue(writer, new KnowledgePackageWrapper(knowledgePackage));
    String content=writer.getBuffer().toString();
    writer.close();
    StringBuffer sb=new StringBuffer();
    List<ClientConfig> clients=repositoryService.loadClientConfigs(project);
    int i=0;
    for(ClientConfig config:clients){
        if(i>0){
            sb.append("<br>");
        }
        boolean result=pushKnowledgePackage(packageId,content,config.getClient());
        if(result){
            sb.append("<span class=\"text-info\" style='line-height:30px'>推送到客户端:"+config.getName()+":"+config.getClient()+" 成功</span>");
        }else{
            sb.append("<span class=\"text-danger\" style='line-height:30px'>推送到客户端:"+config.getName()+":"+config.getClient()+" 失败</span>");
        }
        i++;
    }
    Map<String,Object> map=new HashMap<String,Object>();
    map.put("info", sb.toString());
    writeObjectToJson(resp, map);
}
项目:ureport    文件:WriteJsonServletAction.java   
protected void writeObjectToJson(HttpServletResponse resp,Object obj) throws ServletException, IOException{
    resp.setContentType("text/json");
    resp.setCharacterEncoding("UTF-8");
    ObjectMapper mapper=new ObjectMapper();
    mapper.setSerializationInclusion(Inclusion.NON_NULL);
    mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false);
    mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
    OutputStream out = resp.getOutputStream();
    try {
        mapper.writeValue(out, obj);
    } finally {
        out.flush();
        out.close();
    }
}
项目:aliyun-oss-hadoop-fs    文件:FileSystemTimelineWriter.java   
private ObjectMapper createObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
  mapper.setSerializationInclusion(Inclusion.NON_NULL);
  mapper.configure(Feature.CLOSE_CLOSEABLE, false);
  return mapper;
}
项目:g2    文件:JsonBinder.java   
public JsonBinder(Inclusion inclusion) {  
        mapper = new ObjectMapper();  
        //设置输出包含的属性  
/*        mapper.getSerializationConfig().setSerializationInclusion(inclusion);  
        //设置输入时忽略JSON字符串中存在而Java对象实际没有的属性  
        mapper.getDeserializationConfig().set(  
                org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);  
    */
    }
项目:alfresco-utility    文件:AcosixResteasyJacksonProvider.java   
public AcosixResteasyJacksonProvider()
{
    super();

    final ObjectMapper configuredMapper = this._mapperConfig.getConfiguredMapper();
    final ObjectMapper defaultMapper = this._mapperConfig.getDefaultMapper();

    final ObjectMapper effectiveMapper = configuredMapper != null ? configuredMapper : defaultMapper;
    effectiveMapper.setSerializationInclusion(Inclusion.NON_EMPTY);
}
项目:playground    文件:BasicObjectMapperProvider.java   
/** Create a new object mapper. */
private static ObjectMapper newMapper() {

    final ObjectMapper aMapper = new ObjectMapper();
    aMapper.registerModule(newJodaModule());
    aMapper.setSerializationInclusion(Inclusion.NON_EMPTY);
    aMapper.getSerializerProvider()
        .setNullKeySerializer(NullKeysAsEmptyStringsSerializer.create());

    aMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    addDiscoverableDeserializers(aMapper);
    return aMapper;
}
项目:onboard    文件:WebSocketServiceImpl.java   
/**
 * 根据map生成json
 * 
 * @param actionMap
 * @return
 */
private String getJson(Object activity) {
    ObjectMapper objectMapper = new ObjectMapper();

    objectMapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
    ObjectWriter ow = objectMapper.writer().withDefaultPrettyPrinter();
    String message = "";
    try {
        message = ow.writeValueAsString(activity);
    } catch (IOException e) {
        logger.info("activity to json failure");
    }
    return message;
}
项目:hops    文件:FileSystemTimelineWriter.java   
private ObjectMapper createObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
  mapper.setSerializationInclusion(Inclusion.NON_NULL);
  mapper.configure(Feature.CLOSE_CLOSEABLE, false);
  mapper.configure(Feature.FLUSH_AFTER_WRITE_VALUE, false);
  return mapper;
}
项目:community-edition-old    文件:JacksonHelper.java   
@Override
public void afterPropertiesSet() throws Exception
{
    //Configure the objectMapper ready for use
    objectMapper = new ObjectMapper();
    objectMapper.registerModule(module);
    objectMapper.setSerializationInclusion(Inclusion.NON_EMPTY);  //or NON_EMPTY?
    objectMapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false);
    objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
    DateFormat DATE_FORMAT_ISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    DATE_FORMAT_ISO8601.setTimeZone(TimeZone.getTimeZone("UTC"));
    objectMapper.setDateFormat(DATE_FORMAT_ISO8601);
    objectMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);

}
项目:bitcoin-transaction-explorer    文件:JSONRPCEncoder.java   
public static String getRequestStringWithParameters(final String method, final ArrayList<Object> parameters) throws JsonGenerationException, JsonMappingException, IOException {
  final JSONRPCRequest req = new JSONRPCRequest(method);
  req.setParams(parameters);

  final StringWriter writer = new StringWriter();

  final ObjectMapper mapper = new ObjectMapper();
  mapper.setSerializationInclusion(Inclusion.NON_EMPTY);
  mapper.writeValue(writer, req);

  return writer.toString();
}
项目:Cassandra-rate-limiting-demo    文件:ObjectMapperFactoryBean.java   
public ObjectMapperFactoryBean() {
    this.objectMapper = new ObjectMapper();
    this.objectMapper.setSerializationInclusion(Inclusion.NON_NULL);
    this.objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
    AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

    this.objectMapper.setAnnotationIntrospector(pair);
}
项目:12306-android-Decompile    文件:SerializationConfig.java   
public JsonSerialize.Inclusion getSerializationInclusion()
{
  if (this._serializationInclusion != null)
    return this._serializationInclusion;
  if (isEnabled(Feature.WRITE_NULL_PROPERTIES))
    return JsonSerialize.Inclusion.ALWAYS;
  return JsonSerialize.Inclusion.NON_NULL;
}
项目:12306-android-Decompile    文件:SerializationConfig.java   
public void setSerializationInclusion(JsonSerialize.Inclusion paramInclusion)
{
  this._serializationInclusion = paramInclusion;
  if (paramInclusion == JsonSerialize.Inclusion.NON_NULL)
  {
    disable(Feature.WRITE_NULL_PROPERTIES);
    return;
  }
  enable(Feature.WRITE_NULL_PROPERTIES);
}
项目:12306-android-Decompile    文件:JacksonAnnotationIntrospector.java   
public JsonSerialize.Inclusion findSerializationInclusion(Annotated paramAnnotated, JsonSerialize.Inclusion paramInclusion)
{
  JsonSerialize localJsonSerialize = (JsonSerialize)paramAnnotated.getAnnotation(JsonSerialize.class);
  if (localJsonSerialize != null)
    return localJsonSerialize.include();
  JsonWriteNullProperties localJsonWriteNullProperties = (JsonWriteNullProperties)paramAnnotated.getAnnotation(JsonWriteNullProperties.class);
  if (localJsonWriteNullProperties != null)
  {
    if (localJsonWriteNullProperties.value())
      return JsonSerialize.Inclusion.ALWAYS;
    return JsonSerialize.Inclusion.NON_NULL;
  }
  return paramInclusion;
}
项目:hadoop-on-lustre2    文件:YarnJacksonJaxbJsonProvider.java   
@Override
public ObjectMapper locateMapper(Class<?> type, MediaType mediaType) {
  ObjectMapper mapper = super.locateMapper(type, mediaType);
  AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
  mapper.setAnnotationIntrospector(introspector);
  mapper.getSerializationConfig()
      .setSerializationInclusion(Inclusion.NON_NULL);
  return mapper;
}
项目:yscardII    文件:JsonBinder.java   
@SuppressWarnings("deprecation")
public JsonBinder(Inclusion inclusion) {
    mapper = new ObjectMapper();
    // 设置输出包含的属性
    mapper.getSerializationConfig().setSerializationInclusion(inclusion);
    // 设置输入时忽略JSON字符串中存在而Java对象实际没有的属性
    mapper
            .getDeserializationConfig()
            .set(
                    org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
                    false);
}
项目:openstack-maven-CIET-students    文件:PortTest.java   
public static ObjectMapper initializeObjectMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setSerializationInclusion(Inclusion.NON_NULL)
            .enable(SerializationConfig.Feature.INDENT_OUTPUT)
            .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
            .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
            .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
    return objectMapper;
}
项目:pi    文件:KoalaJsonParser.java   
public KoalaJsonParser() {
    jsonFactory = new JsonFactory();

    mapper = new ObjectMapper();
    mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
    mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
项目:RHome    文件:SerializationConfig.java   
public JsonSerialize.Inclusion getSerializationInclusion()
{
    if (_serializationInclusion != null) {
        return _serializationInclusion;
    }
    return isEnabled(Feature.WRITE_NULL_PROPERTIES) ?
        JsonSerialize.Inclusion.ALWAYS : JsonSerialize.Inclusion.NON_NULL;
}
项目:RHome    文件:SerializationConfig.java   
/**
 * Method that will define global setting of which
 * bean/map properties are to be included in serialization.
 * Can be overridden by class annotations (overriding
 * settings to use for instances of that class) and
 * method/field annotations (overriding settings for the value
 * bean for that getter method or field)
 */
public void setSerializationInclusion(JsonSerialize.Inclusion props)
{
    _serializationInclusion = props;
    // And for some level of backwards compatibility, also...
    if (props == JsonSerialize.Inclusion.NON_NULL) {
        disable(Feature.WRITE_NULL_PROPERTIES);
    } else {
        enable(Feature.WRITE_NULL_PROPERTIES);
    }
}
项目:open-cyclos    文件:CustomJacksonMessageConverter.java   
public CustomJacksonMessageConverter() {
    ObjectMapper objectMapper = new CustomObjectMapper()
            .enable(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)
            .enable(DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS)
            .disable(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)
            .disable(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES);
    objectMapper.setSerializationInclusion(Inclusion.NON_EMPTY);
    setObjectMapper(objectMapper);
}
项目:12306-android-Decompile    文件:SerializationConfig.java   
public JsonSerialize.Inclusion getSerializationInclusion()
{
  if (this._serializationInclusion != null)
    return this._serializationInclusion;
  if (isEnabled(Feature.WRITE_NULL_PROPERTIES))
    return JsonSerialize.Inclusion.ALWAYS;
  return JsonSerialize.Inclusion.NON_NULL;
}
项目:12306-android-Decompile    文件:SerializationConfig.java   
public void setSerializationInclusion(JsonSerialize.Inclusion paramInclusion)
{
  this._serializationInclusion = paramInclusion;
  if (paramInclusion == JsonSerialize.Inclusion.NON_NULL)
  {
    disable(Feature.WRITE_NULL_PROPERTIES);
    return;
  }
  enable(Feature.WRITE_NULL_PROPERTIES);
}
项目:12306-android-Decompile    文件:JacksonAnnotationIntrospector.java   
public JsonSerialize.Inclusion findSerializationInclusion(Annotated paramAnnotated, JsonSerialize.Inclusion paramInclusion)
{
  JsonSerialize localJsonSerialize = (JsonSerialize)paramAnnotated.getAnnotation(JsonSerialize.class);
  if (localJsonSerialize != null)
    return localJsonSerialize.include();
  JsonWriteNullProperties localJsonWriteNullProperties = (JsonWriteNullProperties)paramAnnotated.getAnnotation(JsonWriteNullProperties.class);
  if (localJsonWriteNullProperties != null)
  {
    if (localJsonWriteNullProperties.value())
      return JsonSerialize.Inclusion.ALWAYS;
    return JsonSerialize.Inclusion.NON_NULL;
  }
  return paramInclusion;
}
项目:brigen-base    文件:JsonDelegaterJackson.java   
protected ObjectMapper create(String dateFormat, boolean serializeNulls) {
    ObjectMapper ret = new ObjectMapper();
    if (dateFormat != null) {
        ret.setDateFormat(new SimpleDateFormat(dateFormat));
    }
    if (serializeNulls) {
        ret.setSerializationInclusion(Inclusion.ALWAYS);
    } else {
        ret.setSerializationInclusion(Inclusion.NON_NULL);
    }
    return ret;
}