本文整理汇总了Java中com.alibaba.fastjson.parser.Feature.SupportArrayToBean方法的典型用法代码示例。如果您正苦于以下问题:Java Feature.SupportArrayToBean方法的具体用法?Java Feature.SupportArrayToBean怎么用?Java Feature.SupportArrayToBean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.parser.Feature
的用法示例。
在下文中一共展示了Feature.SupportArrayToBean方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_null_array_reader_1
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_null_array_reader_1() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[null ,null]"), Feature.SupportArrayToBean);
Model model = reader.readObject(Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
示例2: test_1_stream
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_1_stream() throws Exception {
String text = "[123 ,\"wenshao\"]";
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
VO vo2 = reader.readObject(VO.class);
Assert.assertEquals(123, vo2.getId());
Assert.assertEquals("wenshao", vo2.getName());
}
示例3: test_null_array_reader
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_null_array_reader() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[\"null\" ,\"null\"]"), Feature.SupportArrayToBean);
Model model = reader.readObject(Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
示例4: test_error_stream
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_error_stream() throws Exception {
String text = "[123.,\"wenshao\"]";
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
reader.readObject(VO.class);
reader.close();
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例5: test_error_stream_1
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_error_stream_1() throws Exception {
String text = "[123:\"wenshao\" ]";
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
reader.readObject(VO.class);
reader.close();
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例6: test_error_stream_2
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_error_stream_2() throws Exception {
String text = "[-123:\"wenshao\" ]";
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
reader.readObject(VO.class);
reader.close();
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例7: test_error_value_notmatch_stream
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_error_value_notmatch_stream() throws Exception {
String text = "[true,\"wenshao\"]";
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
reader.readObject(VO.class);
reader.close();
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例8: test_2_stream
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_2_stream() throws Exception {
String text = "[-123 ,\"wenshao\"]";
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
VO vo2 = reader.readObject(VO.class);
Assert.assertEquals(-123, vo2.getId());
Assert.assertEquals("wenshao", vo2.getName());
}
示例9: test_error_overflow_stream
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_error_overflow_stream() throws Exception {
String text = "[2147483649:\"wenshao\" ]";
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
reader.readObject(VO.class);
reader.close();
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例10: test_error_value_notmatch_2_stream
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_error_value_notmatch_2_stream() throws Exception {
String text = "[+,\"wenshao\"]";
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
reader.readObject(VO.class);
reader.close();
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例11: test_0
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_0 () throws Exception {
VO vo = new VO();
vo.setId(123);
vo.setName("wenshao");
String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
Assert.assertEquals("[123,\"wenshao\"]", text);
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
VO vo2 = reader.readObject(VO.class);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
reader.close();
}
示例12: test_for_error
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_for_error() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[1001,\"wenshao\"]"), Feature.SupportArrayToBean);
Model model = reader.readObject(Model.class);
Assert.assertEquals(1001, model.id);
Assert.assertEquals("wenshao", model.name);
}
示例13: test_min_array
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_min_array() throws Exception {
V0 v = new V0();
v.setValue(Long.MIN_VALUE);
String text = JSON.toJSONString(v, SerializerFeature.BeanToArray);
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
V0 v1 = reader.readObject(V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
示例14: test_max_array
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_max_array() throws Exception {
V0 v = new V0();
v.setValue(Long.MIN_VALUE);
String text = JSON.toJSONString(v, SerializerFeature.BeanToArray);
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
V0 v1 = reader.readObject(V0.class);
Assert.assertEquals(v.getValue(), v1.getValue());
}