Package com.alibaba.fastjson

Examples of com.alibaba.fastjson.JSONPath$Filter


        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
   
    public void test_list_eq_null() throws Exception {
        JSONPath path = new JSONPath("$[name = null]");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(2, result.size());
        Assert.assertSame(entities.get(2), result.get(0));
        Assert.assertSame(entities.get(3), result.get(1));
    }
View Full Code Here


        Assert.assertSame(entities.get(2), result.get(0));
        Assert.assertSame(entities.get(3), result.get(1));
    }
   
    public void test_list_not_null() throws Exception {
        JSONPath path = new JSONPath("$[name != null]");
       
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));
       
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(2, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
        Assert.assertSame(entities.get(1), result.get(1));
    }
View Full Code Here

        Assert.assertSame(entities.get(0), result.get(0));
        Assert.assertSame(entities.get(1), result.get(1));
    }
   
    public void test_list_gt() throws Exception {
        JSONPath path = new JSONPath("$[name > 'ljw2083']");
       
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));
       
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(1), result.get(0));
    }
View Full Code Here

        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(1), result.get(0));
    }
   
    public void test_list_ge() throws Exception {
        JSONPath path = new JSONPath("$[name >= 'ljw2083']");
       
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));
       
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(2, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
        Assert.assertSame(entities.get(1), result.get(1));
    }
View Full Code Here

        Assert.assertSame(entities.get(0), result.get(0));
        Assert.assertSame(entities.get(1), result.get(1));
    }

    public void test_list_lt() throws Exception {
        JSONPath path = new JSONPath("$[?(@.name < 'wenshao')]");
       
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));
       
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
View Full Code Here

        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
   
    public void test_list_le() throws Exception {
        JSONPath path = new JSONPath("$[name <= 'wenshao']");
       
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));
       
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(2, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
        Assert.assertSame(entities.get(1), result.get(1));
    }
View Full Code Here

import com.alibaba.fastjson.JSONPath;


public class JSONPath_object_filter extends TestCase {
    public void test_object_filter() throws Exception {
        JSONPath path = new JSONPath("[id=123]");
       
        Entity entity = new Entity(123, "ljw2083");
        Assert.assertSame(entity, path.eval(entity));
    }
View Full Code Here

        Assert.assertSame(entity, path.eval(entity));
    }
   

    public void test_object_filter_not_match() throws Exception {
        JSONPath path = new JSONPath("[id=124]");
       
        Entity entity = new Entity(123, "ljw2083");
        Assert.assertNull(path.eval(entity));
    }
View Full Code Here

        list.add(new Object());
        list.add(new Object());
        list.add(new Object());
        list.add(new Object());
        list.add(new Object());
        JSONPath path = new JSONPath("$[2:4]");
        List<Object> result = (List<Object>) path.eval(list);
        Assert.assertEquals(3, result.size());
        Assert.assertSame(list.get(2), result.get(0));
        Assert.assertSame(list.get(3), result.get(1));
        Assert.assertSame(list.get(4), result.get(2));
    }
View Full Code Here

        list.add(new Object());
        list.add(new Object());
        list.add(new Object());
        list.add(new Object());
        list.add(new Object());
        JSONPath path = new JSONPath("$[:4]");
        List<Object> result = (List<Object>) path.eval(list);
        Assert.assertEquals(5, result.size());
        Assert.assertSame(list.get(0), result.get(0));
        Assert.assertSame(list.get(1), result.get(1));
        Assert.assertSame(list.get(2), result.get(2));
        Assert.assertSame(list.get(3), result.get(3));
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.JSONPath$Filter

Copyright © 2018 www.massapicom. 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.