Package siena

Examples of siena.Json


    assertTrue(s.contains("1.0E12"));
    assertTrue(s.contains("2.0E12"));
  }
 
  public void testRemoveAll() {
    Json list = Json.list(1, 2, 3);
    list.removeAll(Json.list(1, 2));
    assertEquals(1, list.size());
    assertEquals(3, list.at(0).asInt());
   
    Json map = Json.map().put("foo", 1).put("bar", 2);
    map.removeAll(Json.map().put("foo", 1));
    assertEquals(1, map.size());
    assertEquals(2, map.get("bar").asInt());
  }
View Full Code Here


    assertEquals(1, map.size());
    assertEquals(2, map.get("bar").asInt());
  }
 
  public void testSumIntegers() {
    Json map1 = Json.map().put("a", 1);
    Json map2 = Json.map().put("a", 2).put("b", 5);
   
    map1.sumIntegers(map2);

    assertEquals(3, map1.get("a").asInt());
    assertEquals(5, map1.get("b").asInt());
View Full Code Here

    assertEquals(3, map1.get("a").asInt());
    assertEquals(5, map1.get("b").asInt());
  }
 
  public void testSumDoubles() {
    Json map1 = Json.map().put("a", 1.5);
    Json map2 = Json.map().put("a", 2.5).put("b", 5);
   
    map1.sumReals(map2);

    assertEquals(4, map1.get("a").asInt());
    assertEquals(5, map1.get("b").asInt());
View Full Code Here

    assertEquals(4, map1.get("a").asInt());
    assertEquals(5, map1.get("b").asInt());
  }
 
  public void sumInteger() {
    Json map1 = Json.map().put("a", 1);
    map1.sumInteger("a", 2);
    assertEquals(3, map1.get("a").asInt());
   
    map1 = Json.map();
    map1.sumInteger("a", 2);
    assertEquals(2, map1.get("a").asInt());
  }
View Full Code Here

    map1.sumInteger("a", 2);
    assertEquals(2, map1.get("a").asInt());
  }
 
  public void sumReal() {
    Json map1 = Json.map().put("a", 1.5);
    map1.sumReal("a", 2.5);
    assertEquals(4, map1.get("a").asInt());
   
    map1 = Json.map();
    map1.sumReal("a", 2.5);
    assertEquals(2.5, map1.get("a").asInt());
  }
View Full Code Here

    map1.sumReal("a", 2.5);
    assertEquals(2.5, map1.get("a").asInt());
  }
 
  public void testPutDefault() {
    Json map = Json.map();
    map.putDefault("a", 2);
    assertEquals(2, map.get("a").asInt());
    map.putDefault("a", 3);
    assertEquals(2, map.get("a").asInt());
  }
View Full Code Here

    map.putDefault("a", 3);
    assertEquals(2, map.get("a").asInt());
  }
 
  public void testEqualsTo() {
    Json a = map();
    Json b = map();
    assertTrue(a.equalsTo(b));

    a = list();
    b = list();
    assertTrue(a.equalsTo(b));

    a = list("foo", "bar");
    b = list("foo", "bar");
    assertTrue(a.equalsTo(b));
   
    a = map().put("foo", "bar");
    b = map().put("foo", "bar");
    assertTrue(a.equalsTo(b));
   
    a = map().put("foo", list("bar"));
    b = map().put("foo", list("bar"));
    assertTrue(a.equalsTo(b));
   
    a = map();
    b = sortedMap();
    assertTrue(a.equalsTo(b));
   
    a = new Json(true);
    b = new Json(true);
    assertTrue(a.equalsTo(b));
   
    a = new Json(1);
    b = new Json(1l);
    assertTrue(a.equalsTo(b));
   
    a = new Json(1.0);
    b = new Json(1l);
    assertTrue(a.equalsTo(b));
   
    a = new Json(null);
    b = new Json(null);
    assertTrue(a.equalsTo(b));

    a = map();
    b = list();
    assertFalse(a.equalsTo(b));

    a = list();
    b = map();
    assertFalse(a.equalsTo(b));
   
    a = list(1, 2, 3, 4);
    b = list(1, 2, 3);
    assertFalse(a.equalsTo(b));
   
    a = map().put("foo", 1);
    b = map().put("bar", 1);
    assertFalse(a.equalsTo(b));
   
    a = new Json(1);
    b = new Json(null);
    assertFalse(a.equalsTo(b));
   
    a = list(1, 3);
    b = list(1, 2);
    assertFalse(a.equalsTo(b));
View Full Code Here

    b = a;
    assertTrue(a.equalsTo(b));
  }
 
  public void testFind() {
    Json data = map().put("foo", list(1, 2, list(1, 2, map().put("bar", 1))));
    Json result = data.find("foo", 2, 2, "bar");
    assertNotNull(result);
    assertEquals(1, result.asInt());
   
    // try to call at() in a map
    result = data.find(1);
    assertNull(result);
   
View Full Code Here

    result = data.find("foo", 3);
    assertNull(result);
  }
 
  public void testEnumerations() {
    Json data = list(Gender.MALE);
    assertEquals("[\"MALE\"]", data.toString());
    assertEquals(Gender.MALE.name(), data.at(0).str());
  }
View Full Code Here

public class JsonSerializer implements Serializer {

  public Document deserialize(InputStream in) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    Json json = Json.load(reader);
    return fromJson(json);
  }
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.