Package us.monoid.web.jp.javacc.JSONPathCompiler

Examples of us.monoid.web.jp.javacc.JSONPathCompiler.JSONPathExpr


   */
  @Test
  public void testJSONPathCompiler() throws ParseException, JSONException {
    System.out.println(this.getClass().getResource("books.json"));
    JSONObject json = read(this.getClass().getResource("books.json"));
    JSONPathExpr evaluator = parse("store.book[0].author");
    Object result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Nigel Rees", result);
   
    evaluator = parse("store.book[category='fiction'].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Evelyn Waugh", result);
   
    evaluator = parse("store.book[!category='reference'].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Evelyn Waugh", result);
   
    evaluator = parse("store.book[price>9].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Evelyn Waugh", result);
   
    evaluator = parse("store.book[price>12.999].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("J. R. R. Tolkien", result);
   
    evaluator = parse("store.book[price>9 && price<12.999].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Evelyn Waugh", result);
   
  }
View Full Code Here


 
  protected void testGeo() throws Exception {
    System.out.println(this.getClass().getResource("geo.json"));
    JSONObject json = read(this.getClass().getResource("geo.json"));
    System.out.println(json);
    JSONPathExpr evaluator = parse("results[address_components.short_name='U.S. 101'].formatted_address");
    Object result = evaluator.eval(json);
    System.out.println(result);
    assertTrue(result.toString().contains("Golden Gate Bridge"));
  }
View Full Code Here

  @Test
  public void testSimplePath() throws Exception {
    System.out.println(this.getClass().getResource("books.json"));
    JSONObject json = read(this.getClass().getResource("books.json"));

    JSONPathExpr evaluator = parse("store.book.reviewed-by");
    Object result = evaluator.eval(json);
    System.out.println(result);
    assertTrue(result instanceof List);
  }
View Full Code Here

   */
  @Test
  public void testJSONPathCompiler() throws ParseException, JSONException {
    System.out.println(this.getClass().getResource("books.json"));
    JSONObject json = read(this.getClass().getResource("books.json"));
    JSONPathExpr evaluator = parse("store.book[0].author");
    Object result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Nigel Rees", result);
   
    evaluator = parse("store.book");
    result = evaluator.eval(json);
    System.out.println(result);
    assertTrue(result instanceof JSONArray);
    evaluator = parse("store.book[category='fiction'].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Evelyn Waugh", result);
   
    evaluator = parse("store.book[!category='reference'].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Evelyn Waugh", result);
   
    evaluator = parse("store.book[price>9].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Evelyn Waugh", result);
   
    evaluator = parse("store.book[price>12.999].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("J. R. R. Tolkien", result);
   
    evaluator = parse("store.book[price>9 && price<12.999].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Evelyn Waugh", result);
   
    evaluator = parse("store.book[reviewed-by.name='JB'].author");
    result = evaluator.eval(json);
    System.out.println(result);
    assertEquals("Nigel Rees", result);
   
   
   
View Full Code Here

 
  @Test
  public void testArray() throws ParseException, JSONException {
    System.out.println(this.getClass().getResource("array-test.json"));
    JSONObject json = read(this.getClass().getResource("array-test.json"));
    JSONPathExpr evaluator = parse("backdrops[image.width=1280]");
    Object result = evaluator.eval(json);
    System.out.println(result);
  }
View Full Code Here

TOP

Related Classes of us.monoid.web.jp.javacc.JSONPathCompiler.JSONPathExpr

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.