1.问题描述
- 经过debug源码发现isValid0方法只要字符串开头是 “{” ,结尾是 “}” ,就都返回true,中间skipObject和skipArray直接跳过了,并没有校验每一个字符的合法性。
2.解决办法
package com.aliyun.flume.interceptor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
/**
 * @author Helz
 * @create 2020-05-13
 */
public class JSONUtils {
    public static boolean isJSONValidate(String log){
        try {
            JSON.parse(log);
            return true;
        } catch (JSONException e) {
            return false;
        }
    }
}









