bug fixed for issue #3460, JSONValidator.supportMultiValue default false

This commit is contained in:
高铁
2020-10-08 18:46:23 +08:00
parent afc024350d
commit dd1cec42ea
2 changed files with 33 additions and 2 deletions
@@ -16,7 +16,7 @@ public abstract class JSONValidator implements Cloneable, Closeable {
protected Type type;
protected int count = 0;
protected boolean supportMultiValue = true;
protected boolean supportMultiValue = false;
public static JSONValidator fromUtf8(byte[] jsonBytes) {
return new UTF8Validator(jsonBytes);
@@ -38,8 +38,9 @@ public abstract class JSONValidator implements Cloneable, Closeable {
return supportMultiValue;
}
public void setSupportMultiValue(boolean supportMultiValue) {
public JSONValidator setSupportMultiValue(boolean supportMultiValue) {
this.supportMultiValue = supportMultiValue;
return this;
}
public Type getType() {
@@ -0,0 +1,30 @@
package com.alibaba.json.bvt.issue_3400;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONValidator;
import com.alibaba.json.bvt.issue_3200.Issue3293;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* Description: <br>
*
* @author byw
* @create 2020/9/20
*/
public class Issue3460 extends TestCase {
public void test_for_issue() throws Exception {
String body = "11{\"time\":" + System.currentTimeMillis() + "}";
assertFalse(
JSONValidator.from(body)
.validate());
assertTrue(
JSONValidator.from(body)
.setSupportMultiValue(true)
.validate());
}
}