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

Examples of us.monoid.web.jp.javacc.JSONPathCompiler.JSONPathExpr.eval()


  @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);
View Full Code Here


    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);
View Full Code Here

    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);
View Full Code Here

    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);
View Full Code Here

    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);
View Full Code Here

    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"));
  }

  @Test
View Full Code Here

  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);
View Full Code Here

    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);
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.