当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMapper.setSerializationInclusion方法代码示例

本文整理汇总了Java中org.codehaus.jackson.map.ObjectMapper.setSerializationInclusion方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.setSerializationInclusion方法的具体用法?Java ObjectMapper.setSerializationInclusion怎么用?Java ObjectMapper.setSerializationInclusion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.jackson.map.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.setSerializationInclusion方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeObjectToJson

import org.codehaus.jackson.map.ObjectMapper; //导入方法依赖的package包/类
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();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:17,代码来源:WriteJsonServletHandler.java

示例2: writeObjectToJson

import org.codehaus.jackson.map.ObjectMapper; //导入方法依赖的package包/类
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();
	}
}
 
开发者ID:youseries,项目名称:uflo,代码行数:17,代码来源:WriteJsonServletHandler.java

示例3: pushKnowledgePackageToClients

import org.codehaus.jackson.map.ObjectMapper; //导入方法依赖的package包/类
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);
}
 
开发者ID:youseries,项目名称:urule,代码行数:37,代码来源:PackageServletHandler.java

示例4: writeObjectToJson

import org.codehaus.jackson.map.ObjectMapper; //导入方法依赖的package包/类
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();
	}
}
 
开发者ID:youseries,项目名称:ureport,代码行数:16,代码来源:WriteJsonServletAction.java

示例5: configObjectMapper

import org.codehaus.jackson.map.ObjectMapper; //导入方法依赖的package包/类
public static void configObjectMapper(ObjectMapper mapper) {
  AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
  mapper.setAnnotationIntrospector(introspector);
  mapper.setSerializationInclusion(Inclusion.NON_NULL);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:YarnJacksonJaxbJsonProvider.java


注:本文中的org.codehaus.jackson.map.ObjectMapper.setSerializationInclusion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。