• 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....
  • 相关阅读:
    博客停止更新了,新博客地址见github
    SSH登录过程
    哈希表结构
    静态链接、动态链接
    编译、汇编、链接、加载
    IO复用 select epoll
    kali安装盘
    linux常用命令
    DDOS攻击防范系统的设计与实现
    20155202《网络对抗》Exp9 web安全基础实践
  • 原文地址:https://www.cnblogs.com/iplus/p/4464715.html
Copyright © 2020-2023  润新知