Jackson怎样转换这样的字符串? String jsonStr = "{dataType:'Custom',regexp:'t\\d+',msg:'输入不正确'}";
2013-08-27 18:40
666 查看
字符串 String jsonStr = "{dataType:'Custom',regexp:'t\\d+',msg:'输入不正确'}";
实体
package com.asiainfolinkage.ems.web.client.bean; import com.fasterxml.jackson.annotation.JsonIgnore; /** * <pre> * 数据库文本验证相关的JSON设置转换类 * 数据来自FiledBean * field_validate jsonStr : * like "{dataType:'Custom',regexp:'t\\d+',msg:'输入不正确'}"(数据来自于t_process_fields表的field_validate字段) * field_style jsonStr: * like "{width : '200',color : 'blue'}"(数据来自于t_process_fields表的field_style字段) * </pre> * @author admin * @time 2013-08-27 */ public class ValidateInfoBean { /**数据类型(是否为空)*/ private String dataType; /**正则表达式*/ private String regexp; /**不符合正则表达式的提示信息*/ private String msg; /**控件宽度*/ private Integer width; /**文本颜色*/ private String color; @JsonIgnore public String getDataType() { return dataType; } public void setDataType(String dataType) { this.dataType = dataType; } @JsonIgnore public String getRegexp() { return regexp; } public void setRegexp(String regexp) { this.regexp = regexp; } @JsonIgnore public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } @JsonIgnore public Integer getWidth() { return width; } public void setWidth(Integer width) { this.width = width; } @JsonIgnore public String getColor() { return color; } public void setColor(String color) { this.color = color; } @Override public String toString() { return "ValidateInfoBean [dataType=" + dataType + ", regexp=" + regexp + ", msg=" + msg + ", width=" + width + ", color=" + color + "]"; } }
这样的JSON字符串(有一定的不规则性,如标题没有引号,存在单引号,存在正则表达式)应该怎样去转换成相应的对象?或者要先做什么预处理?
相关文章推荐
- Jackson怎样转换这样的字符串? String jsonStr = "{dataType:'Custom',regexp:'t\\d+',msg:'输入不正确'}";
- Jackson怎样转换这样的字符串? String jsonStr = "{dataType:'Custom',regexp:'t\\d+',msg:'输入不正确'}";
- 为什么要用eval("({a:'b'})")来将字符串转换成json对象
- js中将字符串转换成json--(//highcharts图表里data数据源必须是数组形势的[{name="test1"},{name="test2"}])
- json格式的字符串使用string.Format()方法报错:输入字符串的格式不正确
- jQuery.ajax() datatype:“json" 转换失败
- var dataObj=eval("("+data+")");//转换为json对象(解决在ajax返回json格式数据的时候明明正确的获取了返回值但是却就是进不去success方法的问题。格式错误)
- Spring Mvc使用Jackson进行json转对象时,遇到的字符串转日期的异常处理(Can not deserialize value of type Date from String)
- String str = "1,2,3,4,5,6" 如何将这个字符串转换成int数组
- [iOS]将含有NSData数据的数组转化为json字符串报错:reason: 'Invalid type in JSON write (NSConcreteMutableData)
- 一个中文汉字算两位,一个英文字母算一位,计算中文和英文混合的字符串长度。字符串:String str = "我不好java";
- JSON的String字符串与Java的List列表对象的相互转换
- 将JSON字符串转换为String对象
- 服务器端返回的JSON字符串 怎样在 JS中转换成可访问的 JSON对象
- C# String.Format格式化json字符串中包含"{" "}"报错问题
- 用jackson实现json和字符串直接的转换
- Java (JSONArray、JSONObject、String字符串中)引号""替换成"-"
- a=re.findall('b',c)报错提示:TypeError:expected string or buffer
- owin 返回json字符串多带了双引号"多了重string转义字符串解决办法
- jquery解析服务器端传输回来string字符,datatype为json时出现的问题