Jackson怎样转换这样的字符串? String jsonStr = "{dataType:'Custom',regexp:'t\d+',msg:'输入不正确'}";

字符串	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字符串(有一定的不规则性,如标题没有引号,存在单引号,存在正则表达式)应该怎样去转换成相应的对象?或者要先做什么预处理?

Meet so Meet. C plusplus I-PLUS....
原文地址:https://www.cnblogs.com/iplus/p/4464715.html