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

  • 相关阅读:
    如何把this指针转换成boost的shared_ptr
    字符指针数组 和 字符指针的指针 即 char ** arr VS char * arr[]
    latex图片自动浮动到最后一页单独占用一页
    Android首次开发的经历
    jvm内存问题诊断1
    性能优化从删除子查询做起
    资治通鉴故事止谤莫如自修
    Forward框架的逆袭:解析Forward+渲染
    FFT镜头效果解析
    最先进的开源游戏引擎KlayGE 4.1发布
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3285667.html
Copyright © 2011-2022 走看看