Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.DefaultExtJSONParser.parseObject()


        Assert.assertEquals(true, entity.isF1());
    }

    public void test_1() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"f2\":true}");
        TestEntity entity = parser.parseObject(TestEntity.class);
        Assert.assertEquals(Boolean.TRUE, entity.getF2());
    }

    public void f_test_2() throws Exception {
        TestEntity a = new TestEntity();
View Full Code Here


        System.out.println(text);

        TestEntity b = new TestEntity();
        {
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            parser.parseObject(b);
        }

        Assert.assertEquals("f1", a.isF1(), b.isF1());
        Assert.assertEquals("f2", a.getF2(), b.getF2());
        Assert.assertEquals("f3", a.getF3(), b.getF3());
View Full Code Here

   
    public void test_0() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{,,,,\"value\":3,\"id\":1}");
        parser.config(Feature.AllowArbitraryCommas, true);
        Entity entity = new Entity();
        parser.parseObject(entity);
        Assert.assertEquals(3, entity.getValue());
    }
   
    public void test_1() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"value\":3,\"id\":1}");
View Full Code Here

   
    public void test_1() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"value\":3,\"id\":1}");
        parser.config(Feature.AllowArbitraryCommas, false);
        Entity entity = new Entity();
        parser.parseObject(entity);
        Assert.assertEquals(3, entity.getValue());
    }

    public static class Entity {
View Full Code Here

            int featureValues = 0;
            DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(),
                                                                   featureValues);

            Entity object = new Entity();
            parser.parseObject(object);
        } catch (JSONException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

            int featureValues = 0;
            DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(),
                                                                   featureValues);

            Entity object = new Entity();
            parser.parseObject(object);
        } catch (JSONException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

        JSON.parseObject(jsonString);

        DefaultExtJSONParser parser = new DefaultExtJSONParser(jsonString);
        User user1 = new User();
        parser.parseObject(user1);

        Assert.assertEquals(user.getAge(), user1.getAge());
        Assert.assertEquals(user.getName(), user1.getName());
        Assert.assertEquals(user.getSalary(), user1.getSalary());
    }
View Full Code Here

        {
            Exception error = null;
            try {
                String text = "{\"reader\":3}";
                DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
                parser.parseObject(ErrorObject.class);
            } catch (Exception ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }
View Full Code Here

        {
            Exception error = null;
            try {
                String text = "{\"name\":3}";
                DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
                parser.parseObject(ErrorObject2.class);
            } catch (Exception ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }
View Full Code Here

public class DateParserTest_sql extends TestCase {

    public void f_test_date_0() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("1294552193254");

        java.sql.Date date = parser.parseObject(java.sql.Date.class);

        Assert.assertEquals(new java.sql.Date(1294552193254L), date);
       
        parser.close();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.