mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-23 09:58:34 +08:00
removed deprecated api DefaultExtJSONParser
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2101 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.fastjson.parser;
|
||||
|
||||
|
||||
/**
|
||||
* @author wenshao[szujobs@hotmail.com]
|
||||
*/
|
||||
@Deprecated
|
||||
public class DefaultExtJSONParser extends DefaultJSONParser {
|
||||
|
||||
public DefaultExtJSONParser(String input){
|
||||
this(input, ParserConfig.getGlobalInstance());
|
||||
}
|
||||
|
||||
public DefaultExtJSONParser(String input, ParserConfig mapping){
|
||||
super(input, mapping);
|
||||
}
|
||||
|
||||
public DefaultExtJSONParser(String input, ParserConfig mapping, int features){
|
||||
super(input, mapping, features);
|
||||
}
|
||||
|
||||
public DefaultExtJSONParser(char[] input, int length, ParserConfig mapping, int features){
|
||||
super(input, length, mapping, features);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.alibaba.fastjson.parser.ParserConfig;
|
||||
public class DateParserTest_sql extends TestCase {
|
||||
|
||||
public void f_test_date_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("1294552193254");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("1294552193254");
|
||||
|
||||
java.sql.Date date = parser.parseObject(java.sql.Date.class);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class DateParserTest_sql extends TestCase {
|
||||
public void test_date_1() throws Exception {
|
||||
int features = JSON.DEFAULT_PARSER_FEATURE;
|
||||
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
java.sql.Date date = parser.parseObject(java.sql.Date.class);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class DateParserTest_sql extends TestCase {
|
||||
|
||||
public void test_date_2() throws Exception {
|
||||
int features = JSON.DEFAULT_PARSER_FEATURE;
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
java.sql.Date date = parser.parseObject(java.sql.Date.class);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DateParserTest_sql extends TestCase {
|
||||
public void test_date_3() throws Exception {
|
||||
int features = JSON.DEFAULT_PARSER_FEATURE;
|
||||
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
java.sql.Date date = parser.parseObject(java.sql.Date.class);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class DateParserTest_sql extends TestCase {
|
||||
public void test_date_4() throws Exception {
|
||||
int features = JSON.DEFAULT_PARSER_FEATURE;
|
||||
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
java.sql.Date date = parser.parseObject(java.sql.Date.class);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.alibaba.fastjson.parser.ParserConfig;
|
||||
public class DateParserTest_sql_timestamp extends TestCase {
|
||||
|
||||
public void f_test_date_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("1294552193254");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("1294552193254");
|
||||
|
||||
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DateParserTest_sql_timestamp extends TestCase {
|
||||
public void test_date_1() throws Exception {
|
||||
int features = JSON.DEFAULT_PARSER_FEATURE;
|
||||
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DateParserTest_sql_timestamp extends TestCase {
|
||||
|
||||
public void test_date_2() throws Exception {
|
||||
int features = JSON.DEFAULT_PARSER_FEATURE;
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DateParserTest_sql_timestamp extends TestCase {
|
||||
public void test_date_3() throws Exception {
|
||||
int features = JSON.DEFAULT_PARSER_FEATURE;
|
||||
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class DateParserTest_sql_timestamp extends TestCase {
|
||||
public void test_date_4() throws Exception {
|
||||
int features = JSON.DEFAULT_PARSER_FEATURE;
|
||||
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
|
||||
|
||||
|
||||
@@ -40,18 +40,18 @@ import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.util.TypeUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class DefaultExtJSONParserTest extends TestCase {
|
||||
|
||||
public void test_parseObject() {
|
||||
new DefaultExtJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 0).close();
|
||||
new DefaultJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 0).close();
|
||||
User user = new User();
|
||||
user.setName("校长");
|
||||
user.setAge(3);
|
||||
@@ -63,7 +63,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
|
||||
JSON.parseObject(jsonString);
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(jsonString);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(jsonString);
|
||||
User user1 = new User();
|
||||
parser.parseObject(user1);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
|
||||
public void testCast() throws Exception {
|
||||
new TypeUtils();
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("");
|
||||
|
||||
Assert.assertNull(castToByte(null));
|
||||
Assert.assertNull(castToShort(null));
|
||||
@@ -134,7 +134,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
}
|
||||
|
||||
public void test_casterror2() {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("");
|
||||
{
|
||||
Exception error = null;
|
||||
try {
|
||||
@@ -228,7 +228,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
}
|
||||
|
||||
public void test_casterror() {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("");
|
||||
|
||||
{
|
||||
Exception error = null;
|
||||
@@ -330,19 +330,19 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
Type[] types = method.getGenericParameterTypes();
|
||||
{
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[0])).get(0) instanceof Map);
|
||||
}
|
||||
{
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[1])).get(0) instanceof User);
|
||||
}
|
||||
{
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseArrayWithType(types[2]);
|
||||
;
|
||||
} catch (Exception ex) {
|
||||
@@ -352,14 +352,14 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
}
|
||||
{
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[3])).get(0) instanceof User);
|
||||
}
|
||||
{
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseArrayWithType(types[4]);
|
||||
;
|
||||
} catch (Exception ex) {
|
||||
@@ -369,7 +369,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
}
|
||||
{
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[5])).get(0) instanceof User);
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseArrayWithType(types[6]);
|
||||
;
|
||||
} catch (Exception ex) {
|
||||
@@ -395,7 +395,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseArrayWithType(types[6]);
|
||||
;
|
||||
} catch (Exception ex) {
|
||||
@@ -412,7 +412,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
|
||||
public void test_not_match() throws Exception {
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123, \"kxxx\":33}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
Assert.assertEquals(true, (parser.parseArray(User.class).get(0) instanceof User));
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123, \"kxxx\":33}]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.config(Feature.IgnoreNotMatch, false);
|
||||
Assert.assertEquals(true, (parser.parseArray(User.class).get(0) instanceof User));
|
||||
} catch (Exception ex) {
|
||||
@@ -434,7 +434,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseArray(User.class);
|
||||
} catch (Exception ex) {
|
||||
error = ex;
|
||||
@@ -445,7 +445,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "{\"reader\":3}";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseObject(ErrorObject.class);
|
||||
} catch (Exception ex) {
|
||||
error = ex;
|
||||
@@ -456,7 +456,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "{\"name\":3}";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseObject(ErrorObject2.class);
|
||||
} catch (Exception ex) {
|
||||
error = ex;
|
||||
@@ -497,7 +497,7 @@ public class DefaultExtJSONParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "{}";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseArray(User.class);
|
||||
} catch (Exception ex) {
|
||||
error = ex;
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
|
||||
public class DefaultExtJSONParserTest_0 extends TestCase {
|
||||
@@ -16,31 +16,31 @@ public class DefaultExtJSONParserTest_0 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("123");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("123");
|
||||
Assert.assertEquals(new Integer(123), (Integer) parser.parse());
|
||||
|
||||
parser.config(Feature.IgnoreNotMatch, false);
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[]");
|
||||
parser.parseArray(Class.class);
|
||||
}
|
||||
|
||||
public void test_2() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{}");
|
||||
parser.parseObject(Object.class);
|
||||
}
|
||||
|
||||
public void test_3() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{}");
|
||||
parser.parseObject(User.class);
|
||||
}
|
||||
|
||||
public void test_error_0() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("123");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("123");
|
||||
parser.parseObject(Class.class);
|
||||
} catch (JSONException e) {
|
||||
error = e;
|
||||
@@ -51,7 +51,7 @@ public class DefaultExtJSONParserTest_0 extends TestCase {
|
||||
public void test_error_1() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[{}]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[{}]");
|
||||
parser.parseArray(Class.class);
|
||||
} catch (JSONException e) {
|
||||
error = e;
|
||||
@@ -62,7 +62,7 @@ public class DefaultExtJSONParserTest_0 extends TestCase {
|
||||
public void test_error_2() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(
|
||||
DefaultJSONParser parser = new DefaultJSONParser(
|
||||
"{\"errorValue\":33}");
|
||||
parser.parseArray(User.class);
|
||||
} catch (JSONException e) {
|
||||
@@ -74,7 +74,7 @@ public class DefaultExtJSONParserTest_0 extends TestCase {
|
||||
public void test_error_3() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(
|
||||
DefaultJSONParser parser = new DefaultJSONParser(
|
||||
"{\"age\"33}");
|
||||
parser.parseArray(User.class);
|
||||
} catch (JSONException e) {
|
||||
@@ -86,7 +86,7 @@ public class DefaultExtJSONParserTest_0 extends TestCase {
|
||||
public void test_error_4() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(
|
||||
DefaultJSONParser parser = new DefaultJSONParser(
|
||||
"[\"age\":33}");
|
||||
parser.parseObject(new User());
|
||||
} catch (JSONException e) {
|
||||
|
||||
@@ -7,19 +7,19 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.json.test.entity.TestEntity;
|
||||
|
||||
public class DefaultExtJSONParserTest_1 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"f1\":true}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{\"f1\":true}");
|
||||
TestEntity entity = parser.parseObject(TestEntity.class);
|
||||
Assert.assertEquals(true, entity.isF1());
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"f2\":true}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{\"f2\":true}");
|
||||
TestEntity entity = parser.parseObject(TestEntity.class);
|
||||
Assert.assertEquals(Boolean.TRUE, entity.getF2());
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class DefaultExtJSONParserTest_1 extends TestCase {
|
||||
|
||||
TestEntity b = new TestEntity();
|
||||
{
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseObject(b);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,42 +8,42 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.json.bvt.parser.DefaultExtJSONParserTest.User;
|
||||
|
||||
public class DefaultExtJSONParserTest_2 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{'a':3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{'a':3}");
|
||||
parser.config(Feature.AllowSingleQuotes, true);
|
||||
A a = parser.parseObject(A.class);
|
||||
Assert.assertEquals(3, a.getA());
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{a:3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
A a = parser.parseObject(A.class);
|
||||
Assert.assertEquals(3, a.getA());
|
||||
}
|
||||
|
||||
public void test_2() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{a:3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
Map a = parser.parseObject(Map.class);
|
||||
Assert.assertEquals(3, a.get("a"));
|
||||
}
|
||||
|
||||
public void test_3() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{a:3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
HashMap a = parser.parseObject(HashMap.class);
|
||||
Assert.assertEquals(3, a.get("a"));
|
||||
}
|
||||
|
||||
public void test_4() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{a:3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
LinkedHashMap a = parser.parseObject(LinkedHashMap.class);
|
||||
Assert.assertEquals(3, a.get("a"));
|
||||
@@ -53,7 +53,7 @@ public class DefaultExtJSONParserTest_2 extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123]";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
parser.parseArray(User.class);
|
||||
} catch (Exception ex) {
|
||||
error = ex;
|
||||
@@ -64,7 +64,7 @@ public class DefaultExtJSONParserTest_2 extends TestCase {
|
||||
public void test_error_1() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{'a'3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{'a'3}");
|
||||
parser.config(Feature.AllowSingleQuotes, true);
|
||||
parser.parseObject(A.class);
|
||||
} catch (JSONException e) {
|
||||
@@ -76,7 +76,7 @@ public class DefaultExtJSONParserTest_2 extends TestCase {
|
||||
public void test_error_2() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{a 3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{a 3}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
parser.parseObject(A.class);
|
||||
} catch (JSONException e) {
|
||||
@@ -88,7 +88,7 @@ public class DefaultExtJSONParserTest_2 extends TestCase {
|
||||
public void test_error_3() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
parser.parseObject(A.class);
|
||||
} catch (JSONException e) {
|
||||
@@ -100,7 +100,7 @@ public class DefaultExtJSONParserTest_2 extends TestCase {
|
||||
public void test_error_4() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"a\"3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{\"a\"3}");
|
||||
parser.parseObject(A.class);
|
||||
} catch (JSONException e) {
|
||||
error = e;
|
||||
@@ -111,7 +111,7 @@ public class DefaultExtJSONParserTest_2 extends TestCase {
|
||||
public void test_error_5() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{a:3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, false);
|
||||
parser.parseObject(A.class);
|
||||
} catch (JSONException e) {
|
||||
@@ -123,7 +123,7 @@ public class DefaultExtJSONParserTest_2 extends TestCase {
|
||||
public void test_error_6() throws Exception {
|
||||
JSONException error = null;
|
||||
try {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{'a':3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{'a':3}");
|
||||
parser.config(Feature.AllowSingleQuotes, false);
|
||||
parser.parseObject(A.class);
|
||||
} catch (JSONException e) {
|
||||
|
||||
@@ -6,21 +6,21 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
|
||||
public class DefaultExtJSONParserTest_3 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{v1:3}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{v1:3}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
A a = parser.parseObject(A.class);
|
||||
Assert.assertEquals(3, a.getV1());
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{v1:'3'}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{v1:'3'}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
parser.config(Feature.AllowSingleQuotes, true);
|
||||
A a = parser.parseObject(A.class);
|
||||
@@ -28,7 +28,7 @@ public class DefaultExtJSONParserTest_3 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_2() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{v1:\"3\"}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{v1:\"3\"}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
parser.config(Feature.AllowSingleQuotes, true);
|
||||
A a = parser.parseObject(A.class);
|
||||
@@ -36,7 +36,7 @@ public class DefaultExtJSONParserTest_3 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_3() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{o1:{}}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{o1:{}}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
parser.config(Feature.AllowSingleQuotes, true);
|
||||
A a = parser.parseObject(A.class);
|
||||
@@ -44,7 +44,7 @@ public class DefaultExtJSONParserTest_3 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_4() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{v5:'3'}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{v5:'3'}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
parser.config(Feature.AllowSingleQuotes, true);
|
||||
A a = parser.parseObject(A.class);
|
||||
@@ -52,7 +52,7 @@ public class DefaultExtJSONParserTest_3 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_5() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{v5:\"3\"}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{v5:\"3\"}");
|
||||
parser.config(Feature.AllowUnQuotedFieldNames, true);
|
||||
parser.config(Feature.AllowSingleQuotes, true);
|
||||
A a = parser.parseObject(A.class);
|
||||
@@ -65,13 +65,13 @@ public class DefaultExtJSONParserTest_3 extends TestCase {
|
||||
|
||||
Assert.assertEquals(true, Feature.isEnabled(features, Feature.AllowSingleQuotes));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("'abc'", ParserConfig.getGlobalInstance(), features);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("'abc'", ParserConfig.getGlobalInstance(), features);
|
||||
|
||||
Assert.assertEquals("abc", parser.parse());
|
||||
}
|
||||
|
||||
public void test_7() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("123");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("123");
|
||||
|
||||
ParserConfig mapping = new ParserConfig();
|
||||
parser.setConfig(mapping);
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class DefaultExtJSONParserTest_4 extends TestCase {
|
||||
String[] tests = { "[1,2,3]", "[1,,2,3]", "[1,2,,,3]", "[1 2,,,3]", "[1 2 3]", "[1, 2, 3,,]", "[,,1, 2, 3,,]", };
|
||||
|
||||
for (String t : tests) {
|
||||
DefaultExtJSONParser ext = new DefaultExtJSONParser(t);
|
||||
DefaultJSONParser ext = new DefaultJSONParser(t);
|
||||
ext.config(Feature.AllowArbitraryCommas, true);
|
||||
List<Object> extRes = ext.parseArray(Object.class);
|
||||
Assert.assertEquals(res, extRes);
|
||||
@@ -42,7 +42,7 @@ public class DefaultExtJSONParserTest_4 extends TestCase {
|
||||
"{,,'a':1,,,,'b':2,'c':3,,,,,}", };
|
||||
|
||||
for (String t : tests) {
|
||||
DefaultExtJSONParser ext = new DefaultExtJSONParser(t);
|
||||
DefaultJSONParser ext = new DefaultJSONParser(t);
|
||||
ext.config(Feature.AllowArbitraryCommas, true);
|
||||
|
||||
JSONObject extRes = ext.parseObject();
|
||||
@@ -65,7 +65,7 @@ public class DefaultExtJSONParserTest_4 extends TestCase {
|
||||
"{,,'a':1,,,,'b':2,,'c':3,,,,,}", };
|
||||
|
||||
for (String t : tests) {
|
||||
DefaultExtJSONParser ext = new DefaultExtJSONParser(t);
|
||||
DefaultJSONParser ext = new DefaultJSONParser(t);
|
||||
ext.config(Feature.AllowArbitraryCommas, true);
|
||||
|
||||
A extRes = ext.parseObject(A.class);
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.alibaba.json.bvt.parser;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
|
||||
public class DefaultExtJSONParserTest_5 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{,,,,\"value\":3,\"id\":1}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{,,,,\"value\":3,\"id\":1}");
|
||||
parser.config(Feature.AllowArbitraryCommas, true);
|
||||
Entity entity = new Entity();
|
||||
parser.parseObject(entity);
|
||||
@@ -17,7 +17,7 @@ public class DefaultExtJSONParserTest_5 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"value\":3,\"id\":1}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{\"value\":3,\"id\":1}");
|
||||
parser.config(Feature.AllowArbitraryCommas, false);
|
||||
Entity entity = new Entity();
|
||||
parser.parseObject(entity);
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.alibaba.json.bvt.parser;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
|
||||
public class DefaultExtJSONParserTest_6 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{value:{,,,,\"value\":3,\"id\":1}}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{value:{,,,,\"value\":3,\"id\":1}}");
|
||||
parser.config(Feature.AllowArbitraryCommas, true);
|
||||
Entity entity = new Entity();
|
||||
parser.parseObject(entity);
|
||||
@@ -17,7 +17,7 @@ public class DefaultExtJSONParserTest_6 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{'value':{\"value\":3,\"id\":1}}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{'value':{\"value\":3,\"id\":1}}");
|
||||
parser.config(Feature.AllowArbitraryCommas, false);
|
||||
Entity entity = new Entity();
|
||||
parser.parseObject(entity);
|
||||
|
||||
@@ -8,13 +8,13 @@ import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
|
||||
public class DefaultExtJSONParserTest_7 extends TestCase {
|
||||
|
||||
public void test_parse() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("1");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("1");
|
||||
Assert.assertEquals(Integer.valueOf(1), parser.parse());
|
||||
|
||||
Exception error = null;
|
||||
@@ -27,14 +27,14 @@ public class DefaultExtJSONParserTest_7 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_parse_str() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"1\"");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("\"1\"");
|
||||
parser.config(Feature.AllowISO8601DateFormat, true);
|
||||
Assert.assertEquals("1", parser.parse());
|
||||
|
||||
}
|
||||
|
||||
public void test_parseArray() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1]");
|
||||
parser.config(Feature.AllowArbitraryCommas, false);
|
||||
List<String> list = new ArrayList<String>();
|
||||
parser.parseArray(String.class, list);
|
||||
@@ -42,7 +42,7 @@ public class DefaultExtJSONParserTest_7 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_parseArray_error() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2}");
|
||||
parser.config(Feature.AllowArbitraryCommas, false);
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
|
||||
@@ -11,21 +11,21 @@ import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
|
||||
public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,,,3]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2,,,3]");
|
||||
List list = new ArrayList();
|
||||
parser.parseArray(int.class, list);
|
||||
Assert.assertEquals("[1, 2, 3]", list.toString());
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3]");
|
||||
parser.config(Feature.AllowArbitraryCommas, true);
|
||||
List list = new ArrayList();
|
||||
parser.parseArray(int.class, list);
|
||||
@@ -33,7 +33,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_2() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("['1','2','3']");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("['1','2','3']");
|
||||
parser.config(Feature.AllowArbitraryCommas, true);
|
||||
List list = new ArrayList();
|
||||
parser.parseArray(String.class, list);
|
||||
@@ -42,7 +42,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_3() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3]");
|
||||
parser.config(Feature.AllowArbitraryCommas, true);
|
||||
List list = new ArrayList();
|
||||
parser.parseArray(BigDecimal.class, list);
|
||||
@@ -51,7 +51,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_4() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3,null]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3,null]");
|
||||
parser.config(Feature.AllowArbitraryCommas, true);
|
||||
List list = new ArrayList();
|
||||
parser.parseArray(BigDecimal.class, list);
|
||||
@@ -60,7 +60,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_5() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3,null]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3,null]");
|
||||
Object[] array = parser.parseArray(new Type[] { Integer.class, BigDecimal.class, Long.class, String.class });
|
||||
Assert.assertEquals(new Integer(1), array[0]);
|
||||
Assert.assertEquals(new BigDecimal("2"), array[1]);
|
||||
@@ -69,7 +69,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{}");
|
||||
Exception error = null;
|
||||
try {
|
||||
parser.parseArray(new ArrayList());
|
||||
@@ -80,7 +80,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_6() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1.2]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1.2]");
|
||||
parser.config(Feature.UseBigDecimal, false);
|
||||
ArrayList list = new ArrayList();
|
||||
parser.parseArray(list);
|
||||
@@ -88,7 +88,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_7() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[\"2011-01-09T13:49:53.254\", \"xxx\", true, false, null, {}]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[\"2011-01-09T13:49:53.254\", \"xxx\", true, false, null, {}]");
|
||||
parser.config(Feature.AllowISO8601DateFormat, true);
|
||||
ArrayList list = new ArrayList();
|
||||
parser.parseArray(list);
|
||||
@@ -101,21 +101,21 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_8() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53.254\"");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"");
|
||||
parser.config(Feature.AllowISO8601DateFormat, true);
|
||||
Object value = parser.parse();
|
||||
Assert.assertEquals(new Date(1294552193254L), value);
|
||||
}
|
||||
|
||||
public void test_9() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("");
|
||||
parser.config(Feature.AllowISO8601DateFormat, true);
|
||||
Object value = parser.parse();
|
||||
Assert.assertEquals(null, value);
|
||||
}
|
||||
|
||||
public void test_error_2() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{}");
|
||||
Exception error = null;
|
||||
try {
|
||||
parser.accept(JSONToken.NULL);
|
||||
@@ -126,7 +126,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_10() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3]");
|
||||
Object[] array = parser.parseArray(new Type[] { Integer[].class });
|
||||
Integer[] values = (Integer[]) array[0];
|
||||
Assert.assertEquals(new Integer(1), values[0]);
|
||||
@@ -135,31 +135,31 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_11() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1]");
|
||||
Object[] array = parser.parseArray(new Type[] { String.class });
|
||||
Assert.assertEquals("1", array[0]);
|
||||
}
|
||||
|
||||
public void test_12() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("['1']");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("['1']");
|
||||
Object[] array = parser.parseArray(new Type[] { int.class });
|
||||
Assert.assertEquals(new Integer(1), array[0]);
|
||||
}
|
||||
|
||||
public void test_13() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("['1']");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("['1']");
|
||||
Object[] array = parser.parseArray(new Type[] { Integer.class });
|
||||
Assert.assertEquals(new Integer(1), array[0]);
|
||||
}
|
||||
|
||||
public void test_14() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[]");
|
||||
Object[] array = parser.parseArray(new Type[] {});
|
||||
Assert.assertEquals(0, array.length);
|
||||
}
|
||||
|
||||
public void test_15() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,null]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,null]");
|
||||
ArrayList list = new ArrayList();
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
parser.parseArray(String.class, list);
|
||||
@@ -168,7 +168,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_16() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[[1]]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[[1]]");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
Object[] array = parser.parseArray(new Type[] { new TypeReference<List<Integer>>() {
|
||||
}.getType() });
|
||||
@@ -176,14 +176,14 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_17() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[]");
|
||||
Object[] array = parser.parseArray(new Type[] { Integer[].class });
|
||||
Integer[] values = (Integer[]) array[0];
|
||||
Assert.assertEquals(0, values.length);
|
||||
}
|
||||
|
||||
public void test_18() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
List<Integer> list = (List<Integer>) parser.parseArrayWithType(new TypeReference<List<Integer>>() {
|
||||
}.getType());
|
||||
@@ -191,7 +191,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_var() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,null }");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2,null }");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
@@ -204,7 +204,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_3() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,null }");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,null }");
|
||||
ArrayList list = new ArrayList();
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
@@ -218,7 +218,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_4() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,null }");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,null }");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
@@ -231,7 +231,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_5() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,null }");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,null }");
|
||||
ArrayList list = new ArrayList();
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
@@ -245,7 +245,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_6() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{1,null }");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{1,null }");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
@@ -258,7 +258,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_7() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{1}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{1}");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
@@ -271,7 +271,7 @@ public class DefaultExtJSONParser_parseArray extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_8() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3 4]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3 4]");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
|
||||
@@ -10,14 +10,14 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultExtJSONParser_parseArray_2 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[['1']]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[['1']]");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
List<List<Integer>> list = (List<List<Integer>>) parser.parseArrayWithType(new TypeReference<List<List<Integer>>>() {
|
||||
}.getType());
|
||||
@@ -25,7 +25,7 @@ public class DefaultExtJSONParser_parseArray_2 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("['1','2']");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("['1','2']");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
parser.parseArray(Integer.class, list);
|
||||
@@ -34,7 +34,7 @@ public class DefaultExtJSONParser_parseArray_2 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("['1','2'}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("['1','2'}");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
@@ -48,7 +48,7 @@ public class DefaultExtJSONParser_parseArray_2 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_1() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[['1']]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[['1']]");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
@@ -62,7 +62,7 @@ public class DefaultExtJSONParser_parseArray_2 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_2() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[new X()]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[new X()]");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
List list = new ArrayList();
|
||||
@@ -76,7 +76,7 @@ public class DefaultExtJSONParser_parseArray_2 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_3() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[] a");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[] a");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
List list = new ArrayList();
|
||||
@@ -91,7 +91,7 @@ public class DefaultExtJSONParser_parseArray_2 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_4() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("['1','2'}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("['1','2'}");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
@@ -104,14 +104,14 @@ public class DefaultExtJSONParser_parseArray_2 extends TestCase {
|
||||
}
|
||||
|
||||
public void test_error_5() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("[]");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("[]");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Assert.assertEquals(1, parser.parseArray(new Type[] { Integer[].class }).length);
|
||||
}
|
||||
|
||||
public void test_error_6() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("['1' 1 '2'}");
|
||||
DefaultJSONParser parser = new DefaultJSONParser("['1' 1 '2'}");
|
||||
parser.config(Feature.AllowISO8601DateFormat, false);
|
||||
|
||||
Exception error = null;
|
||||
|
||||
@@ -3,14 +3,14 @@ package com.alibaba.json.bvt.parser;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.deserializer.EnumDeserializer;
|
||||
|
||||
public class EnumParserTest extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
String text = "\"A\"";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
|
||||
Type type = parser.parseObject(Type.class);
|
||||
Assert.assertEquals(Type.A, type);
|
||||
@@ -18,7 +18,7 @@ public class EnumParserTest extends TestCase {
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String text = "0";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
|
||||
Type type = parser.parseObject(Type.class);
|
||||
Assert.assertEquals(Type.A, type);
|
||||
@@ -28,7 +28,7 @@ public class EnumParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "\"C\"";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
|
||||
parser.parseObject(Type.class);
|
||||
} catch (Exception ex) {
|
||||
@@ -41,7 +41,7 @@ public class EnumParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "4";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
|
||||
parser.parseObject(Type.class);
|
||||
} catch (Exception ex) {
|
||||
@@ -54,7 +54,7 @@ public class EnumParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "4";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
|
||||
parser.parseObject(TypeA.class);
|
||||
} catch (Exception ex) {
|
||||
@@ -67,7 +67,7 @@ public class EnumParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "4";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
|
||||
new EnumDeserializer(Object.class).deserialze(parser, Object.class, null);
|
||||
} catch (Exception ex) {
|
||||
@@ -80,7 +80,7 @@ public class EnumParserTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
String text = "true";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text);
|
||||
|
||||
new EnumDeserializer(Object.class).deserialze(parser, Object.class, null);
|
||||
} catch (Exception ex) {
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ArrayListStringDeserializerTest extends TestCase {
|
||||
featureValues = Feature.config(featureValues, feature, true);
|
||||
}
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
|
||||
T value = (T) parser.parseObject(clazz);
|
||||
|
||||
if (clazz != JSONArray.class) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.BigDecimalCodec;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class BigDecimalDeserializerTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(null, JSON.parseObject("null", BigDecimal.class));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, BigDecimalCodec.instance.deserialze(parser, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -21,7 +21,7 @@ public class DefaultObjectDeserializerTest2 extends TestCase {
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String input = "{'map':{}}";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
|
||||
SortedMap<String, SortedMap> map = JSON.parseObject(input, new TypeReference<SortedMap<String, SortedMap>>() {
|
||||
|
||||
@@ -3,14 +3,14 @@ package com.alibaba.json.bvt.parser.deser;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
|
||||
public class DefaultObjectDeserializerTest4 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"id\":3, \"name\":\"xx\"}", ParserConfig.getGlobalInstance());
|
||||
DefaultJSONParser parser = new DefaultJSONParser("{\"id\":3, \"name\":\"xx\"}", ParserConfig.getGlobalInstance());
|
||||
|
||||
Entity entity = new Entity();
|
||||
parser.parseObject(entity);
|
||||
|
||||
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FieldDeserializerTest2 extends TestCase {
|
||||
String input = "{,,,\"value\":null,,,,}";
|
||||
int featureValues = 0;
|
||||
featureValues |= Feature.AllowArbitraryCommas.getMask();
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
|
||||
|
||||
Entity object = new Entity();
|
||||
parser.parseObject(object);
|
||||
@@ -26,7 +26,7 @@ public class FieldDeserializerTest2 extends TestCase {
|
||||
int featureValues = 0;
|
||||
featureValues |= Feature.AllowArbitraryCommas.getMask();
|
||||
featureValues |= Feature.IgnoreNotMatch.getMask();
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
|
||||
|
||||
Entity object = new Entity();
|
||||
parser.parseObject(object);
|
||||
@@ -37,7 +37,7 @@ public class FieldDeserializerTest2 extends TestCase {
|
||||
try {
|
||||
String input = "{\"value\":null,\"id\":123}";
|
||||
int featureValues = 0;
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
|
||||
|
||||
Entity object = new Entity();
|
||||
parser.parseObject(object);
|
||||
|
||||
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
|
||||
public class FieldDeserializerTest3 extends TestCase {
|
||||
@@ -15,7 +15,7 @@ public class FieldDeserializerTest3 extends TestCase {
|
||||
try {
|
||||
String input = "{\"value\":null}";
|
||||
int featureValues = 0;
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(),
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
|
||||
featureValues);
|
||||
|
||||
Entity object = new Entity();
|
||||
@@ -31,7 +31,7 @@ public class FieldDeserializerTest3 extends TestCase {
|
||||
try {
|
||||
String input = "{,,\"value\":null}";
|
||||
int featureValues = 0;
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(),
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
|
||||
featureValues);
|
||||
|
||||
Entity object = new Entity();
|
||||
|
||||
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.FloatCodec;
|
||||
@@ -19,7 +19,7 @@ public class FloatDeserializerTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(null, JSON.parseObject("null", Float.class));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, FloatCodec.instance.deserialze(parser, null, null));
|
||||
Assert.assertEquals(JSONToken.LITERAL_INT, FloatCodec.instance.getFastMatchToken());
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.alibaba.json.bvt.parser.deser;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.MiscCodec;
|
||||
import com.alibaba.fastjson.serializer.StringCodec;
|
||||
@@ -14,7 +14,7 @@ public class InetAddressDeserializerTest extends TestCase {
|
||||
|
||||
public void test_null() throws Exception {
|
||||
String input = "null";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
MiscCodec deser = new MiscCodec();
|
||||
|
||||
@@ -23,7 +23,7 @@ public class InetAddressDeserializerTest extends TestCase {
|
||||
|
||||
public void test_string_null() throws Exception {
|
||||
String input = "null";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
StringCodec deser = new StringCodec();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class InetAddressDeserializerTest extends TestCase {
|
||||
|
||||
public void test_error_0() throws Exception {
|
||||
String input = "'[&中国-^]'";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
MiscCodec deser = new MiscCodec();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.IntegerCodec;
|
||||
@@ -19,7 +19,7 @@ public class IntegerDeserializerTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(null, JSON.parseObject("null", Integer.class));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, IntegerCodec.instance.deserialze(parser, null, null));
|
||||
Assert.assertEquals(JSONToken.LITERAL_INT, IntegerCodec.instance.getFastMatchToken());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.Locale;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.MiscCodec;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class LocaleTest extends TestCase {
|
||||
|
||||
public void test_null() throws Exception {
|
||||
String input = "null";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
MiscCodec deser = new MiscCodec();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.LongCodec;
|
||||
@@ -19,7 +19,7 @@ public class LongDeserializerTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(null, JSON.parseObject("null", Long.class));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, LongCodec.instance.deserialze(parser, null, null));
|
||||
Assert.assertEquals(JSONToken.LITERAL_INT, LongCodec.instance.getFastMatchToken());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.regex.Pattern;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.MiscCodec;
|
||||
@@ -19,7 +19,7 @@ public class PatternDeserializerTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(null, JSON.parseObject("null", Pattern.class));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
|
||||
Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.parser.deserializer.SqlDateDeserializer;
|
||||
@@ -18,7 +18,7 @@ public class SqlDateDeserializerTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(null, JSON.parseObject("null", Integer.class));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, SqlDateDeserializer.instance.deserialze(parser, null, null));
|
||||
Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.parser.deserializer.NumberDeserializer;
|
||||
import com.alibaba.fastjson.serializer.CharacterCodec;
|
||||
@@ -13,25 +13,25 @@ import com.alibaba.fastjson.serializer.CharacterCodec;
|
||||
public class TestNull extends TestCase {
|
||||
|
||||
public void test_byte() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
Assert.assertNull(new NumberDeserializer().deserialze(parser, null, null));
|
||||
}
|
||||
|
||||
public void test_char() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
Assert.assertNull(new CharacterCodec().deserialze(parser, null, null));
|
||||
}
|
||||
|
||||
public void test_short() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
Assert.assertNull(new NumberDeserializer().deserialze(parser, null, null));
|
||||
}
|
||||
|
||||
public void test_null() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
Assert.assertNull(new NumberDeserializer().deserialze(parser, null, null));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.alibaba.json.bvt.parser.deser;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.MiscCodec;
|
||||
@@ -12,7 +12,7 @@ import junit.framework.TestCase;
|
||||
|
||||
public class TimeZoneDeserializerTest extends TestCase {
|
||||
public void test_timezone() throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
|
||||
Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.alibaba.json.bvt.parser.deser;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.MiscCodec;
|
||||
@@ -14,7 +14,7 @@ public class URIDeserializerTest extends TestCase {
|
||||
|
||||
public void test_null() throws Exception {
|
||||
String input = "null";
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
|
||||
MiscCodec deser = new MiscCodec();
|
||||
Assert.assertEquals(JSONToken.LITERAL_STRING, deser.getFastMatchToken());
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.MiscCodec;
|
||||
@@ -20,7 +20,7 @@ public class URLDeserializerTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(null, JSON.parseObject("null", URL.class));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
|
||||
Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.JSONToken;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.MiscCodec;
|
||||
@@ -21,7 +21,7 @@ public class UUIDDeserializerTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(null, JSON.parseObject("null", UUID.class));
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
|
||||
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
|
||||
Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
@@ -66,7 +66,7 @@ public class BooleanFieldSerializerTest extends TestCase {
|
||||
ParserConfig config = new ParserConfig();
|
||||
config.setAsmEnable(false);
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, config, featureValues);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
|
||||
T value = (T) parser.parseObject(clazz);
|
||||
|
||||
if (clazz != JSONArray.class) {
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
@@ -78,7 +78,7 @@ public class BooleanFieldSerializerTest_primitive extends TestCase {
|
||||
ParserConfig config = new ParserConfig();
|
||||
config.setAsmEnable(false);
|
||||
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(input, config, featureValues);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
|
||||
T value = (T) parser.parseObject(clazz);
|
||||
|
||||
if (clazz != JSONArray.class) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.alibaba.json.test.codec;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
@@ -21,14 +21,14 @@ public class FastjsonBeanToArrayCodec implements Codec {
|
||||
}
|
||||
|
||||
public <T> T decodeObject(String text, Class<T> clazz) {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text, config);
|
||||
parser.config(Feature.DisableCircularReferenceDetect, true);
|
||||
parser.config(Feature.SupportArrayToBean, true);
|
||||
return parser.parseObject(clazz);
|
||||
}
|
||||
|
||||
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text, config);
|
||||
parser.config(Feature.DisableCircularReferenceDetect, true);
|
||||
parser.config(Feature.SupportArrayToBean, true);
|
||||
return parser.parseArray(clazz);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.alibaba.json.test.codec;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
@@ -21,13 +21,13 @@ public class FastjsonCodec implements Codec {
|
||||
}
|
||||
|
||||
public <T> T decodeObject(String text, Class<T> clazz) {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text, config);
|
||||
parser.config(Feature.DisableCircularReferenceDetect, true);
|
||||
return parser.parseObject(clazz);
|
||||
}
|
||||
|
||||
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text, config);
|
||||
parser.config(Feature.DisableCircularReferenceDetect, true);
|
||||
return parser.parseArray(clazz);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.alibaba.json.test.codec;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
@@ -22,14 +22,14 @@ public class FastjsonSCodec implements Codec {
|
||||
|
||||
public <T> T decodeObject(String text, Class<T> clazz) {
|
||||
ParserConfig config = new ParserConfig();
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text, config);
|
||||
parser.config(Feature.DisableCircularReferenceDetect, true);
|
||||
return parser.parseObject(clazz);
|
||||
}
|
||||
|
||||
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
|
||||
ParserConfig config = new ParserConfig();
|
||||
DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
|
||||
DefaultJSONParser parser = new DefaultJSONParser(text, config);
|
||||
parser.config(Feature.DisableCircularReferenceDetect, true);
|
||||
return parser.parseArray(clazz);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user