【正则】json字符串里面的正则表达式包含小数点,导致转换对象失败

前言

示例:

{
    
    
    "friendSumUperLimit":"^[0-9]+$",
    "presentRatio":"^[0-9]+(\.[0-9]{0,2})?$",
    "repeatRatio":"^[0-9]+(\.[0-9]{0,2})?$"
}

解决办法:多加一个斜杠

{
    
    
    "friendSumUperLimit":"^[0-9]+$",
    "presentRatio":"^[0-9]+(\\.[0-9]{0,2})?$",
    "repeatRatio":"^[0-9]+(\\.[0-9]{0,2})?$"
}

猜你喜欢

转载自blog.csdn.net/s1441101265/article/details/111317157