jsonWorkflowBean是json字符串
// 转换成Json对象
JSONObject jsonObj = JSONObject.fromObject(jsonWorkflowBean);/*
* 在JSONObject.toBean的时候如果转换的类中有集合,可以先定义Map<String, Class> classMap
* = new HashMap<String,
* Class>();在classMap中put你要转换的类中的集合名,像:classMap.put("teachers",
* Teacher.class);然后在toBean()的时候把参数加上, 像:Student student=(Student)
* JSONObject.toBean(str, Student.class, classMap);
*/
Map<String, Class> classMap = new HashMap<String, Class>();
classMap.put("inputDataList", InputDataBean.class);
classMap.put("imageList", ImageBean.class);
//将json转换成workflowBean
WorkflowBean workflow = (WorkflowBean) JSONObject.toBean(jsonObj,
WorkflowBean.class, classMap);
分享到:
相关推荐
List<Bean>转换为List<Map>, List<Object>转换为List<Object> list转化为 JsonArray ,list转换JsonArray
JSONObject jsonObject =JSONObject.fromObject(new JsonBean()); 4. 数组转换成json代码 boolean[] boolArray = newboolean[] { true, false, true }; JSONArray jsonArray1 =JSONArray.fromObject(boolArray); ...
//Collection对象转换成JSON @Test public void testListToJSON(){ List list = new ArrayList(); list.add( "first" ); list.add( "second" ); JSONArray jsonArray = JSONArray.fromObject( list ); ...
object , bean , list 转json工具
14. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> 15. 16. <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 --> 17. <bean class="org....
<bean id="xbDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${db.driver}" /> <property name="url" value="${db.url}" /> ...
JSONArray jsonArray = JSONArray.fromObject("['json','is','easy']"); System.out.println(jsonArray); // prints ["json","is","easy"] } public void map2json() { Map map.put("name", "json");...
1.基本的序列化 String objJson = JSON.toJSONString(Object object); 2反序列化(反序列化就是把JSON格式的字符串转化为Java Bean对象) ...List<Map> list1 = JSON.parseArray(listJson, Map.class);
大家都知道jsonlib2.4之后有了属性过滤的功能,就是当把一个bean转成json的时候能指定哪些属性输出哪些不输出,不过代码很难看,如下 JsonConfig config = new JsonConfig(); config.setJsonPropertyFilter(new ...
JSON依赖包,共7个,含示范代码 ,介绍比较全面,如:String json = "{\"doctype\":\"cy\",\"title\":\"重庆\",\"used\":\"商务宴请\"}"; JSONObject jsonObject = JSONObject.fromObject(json); ...
在有状态SessionBean中,用累加器,以对话状态存储起来,创建EJB对象,并将当前的计数器初始化,调用每一个EJB对象的count()方法,保证Bean正常被激活和钝化,EJB对象是用完毕,从内存中清除…… Java Socket 聊天...
6个目标文件,EJB来模拟银行ATM机的流程及操作:获取系统属性,初始化JNDI,取得Home对象的引用,创建EJB对象,并将当前的计数器初始化,调用每一个EJB对象的count()方法,保证Bean正常被激活和钝化,EJB对象是用...
{1.6}数据类型转换}{26}{section.1.6} {1.7}方法}{26}{section.1.7} {1.8}运算符}{27}{section.1.8} {1.8.1}自增运算}{28}{subsection.1.8.1} {1.8.1.1}Postincrement}{28}{subsubsection.1.8.1.1} {1.8.1.2}...