All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.taobao.api.internal.util.json.JSONValidatingReader Maven / Gradle / Ivy

There is a newer version: 1.8.10
Show newest version
package com.taobao.api.internal.util.json;

public class JSONValidatingReader extends JSONReader {
    public static final Object INVALID = new Object();
    private JSONValidator validator;
    
    public JSONValidatingReader(JSONValidator validator) {
        this.validator = validator;
    }
    
    public JSONValidatingReader(JSONErrorListener listener) {
        this(new JSONValidator(listener));
    }
    
    public JSONValidatingReader() {
        this(new StdoutStreamErrorListener());
    }

    public Object read(String string) {
        if (!validator.validate(string)) return INVALID;
        return super.read(string);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy