Package siena

Examples of siena.Json


          if (jsonStr != null && jsonStr.length > 0 && !jsonStr[0].equals("")) {
            try {
              //com.google.gson.JsonParser parser = new com.google.gson.JsonParser();
              //parser.parse(jsonStr[0]);
             
              Json json = Json.loads(jsonStr[0]);
              if(json!=null){
                bw.set(field.getName(), o, json);
                params.remove(name + "." + field.getName());
              }
              else Validation.addError(name+"."+field.getName(), "validation.notParsable");
View Full Code Here


       
        public Employee(Employee emp){
          this.firstName = emp.firstName;
          this.lastName = emp.lastName;
          this.pwd = emp.pwd;
          this.contactInfo = new Json(emp.contactInfo);
          this.hireDate = emp.hireDate;
          this.fireDate = emp.fireDate;
          this.boss = emp.boss;
          this.enumField = emp.enumField;
          // ...
View Full Code Here

                f.set(model, objects.get(key).get(f.getName()));
              } else if (f.getType().equals(byte[].class)) {
                                f.set(model, objects.get(key).get(f.getName()));
                            } else if(Json.class.isAssignableFrom(f.getType())){
                              Object obj = objects.get(key).get(f.getName());
                              Json json = new Json(obj);
                  if(json!=null){
                    f.set(model, json);
                  }
                            } else if(f.isAnnotationPresent(Embedded.class) && List.class.isAssignableFrom(f.getType())){
                               Object obj = objects.get(key).get(f.getName());
View Full Code Here

    assertEquals(2, json.at(1).asInt());
    assertEquals(3, json.at(2).asInt());
  }
 
  public void testRemoveAt() {
    Json json = Json.list(1, 2, 3);
    json.removeAt(1);

    assertEquals(2, json.size());
    assertEquals(1, json.at(0).asInt());
    assertEquals(3, json.at(1).asInt());
  }
View Full Code Here

    assertEquals(1, json.at(0).asInt());
    assertEquals(3, json.at(1).asInt());
  }
 
  public void testIndexOf() {
    Json json = Json.list(1, 2, 3, "hello", true, false, null);

    assertEquals(0, json.indexOf(1));
    assertEquals(1, json.indexOf(2));
    assertEquals(2, json.indexOf(3));
    assertEquals(3, json.indexOf("hello"));
    assertEquals(4, json.indexOf(true));
    assertEquals(5, json.indexOf(false));
    assertEquals(6, json.indexOf(null));
  }
View Full Code Here

    assertEquals(5, json.indexOf(false));
    assertEquals(6, json.indexOf(null));
  }
 
  public void testRemoveKey() {
    Json json = Json.map().put("foo", "bar");
    json.remove("foo");
    assertTrue(json.isEmpty());
  }
View Full Code Here

    json.remove("foo");
    assertTrue(json.isEmpty());
  }
 
  public void testSortedMap() {
    Json json = Json.sortedMap().put("1", 1).put("400", 400).put("3", 3).put("2", 2);
   
    Iterator<String> keys = json.keys().iterator();
    assertEquals("1", keys.next());
    assertEquals("2", keys.next());
    assertEquals("3", keys.next());
    assertEquals("400", keys.next());
  }
View Full Code Here

    assertEquals("3", keys.next());
    assertEquals("400", keys.next());
  }
 
  public void testSortedMap2() {
    Json json = Json.sortedMap().put("2009-01", 1).put("2008-10", 400);
    Iterator<String> keys = json.keys().iterator();
    assertEquals("2008-10", keys.next());
    assertEquals("2009-01", keys.next());
  }
View Full Code Here

    assertEquals("2008-10", keys.next());
    assertEquals("2009-01", keys.next());
  }
 
  public void testContains() {
    Json json = Json.list(1, 2, 3);
    assertTrue(json.contains(1));
    assertTrue(json.contains(2));
    assertTrue(json.contains(3));
    assertFalse(json.contains(4));
  }
View Full Code Here

    assertTrue(json.contains(3));
    assertFalse(json.contains(4));
  }
 
  public void testFormatAndParseNumbers() {
    Json json = Json.loads("[1.0, 2.0, 3, 4, 5, 6.1, 1.0e12, 2e12]");
    String s = json.toString();
    assertTrue(s.contains("1.0"));
    assertTrue(s.contains("2.0"));
    assertFalse(s.contains("3.0"));
    assertFalse(s.contains("4.0"));
    assertFalse(s.contains("5.0"));
View Full Code Here

TOP

Related Classes of siena.Json

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.