Search in sources :

Example 21 with Inspector

use of com.yahoo.data.access.Inspector in project vespa by vespa-engine.

the class JSONStringTestCase method testArrayOfArray.

@Test
public void testArrayOfArray() {
    String json = "[[\"c1\", 0], [\"c2\", 2, 3], [\"c3\", 3, 4, 5], [\"c4\", 4,5,6,7]]";
    JSONString js = new JSONString(json);
    Inspector outer = js.inspect();
    assertEquals(4, outer.entryCount());
    assertEquals(2, outer.entry(0).entryCount());
    assertEquals("c1", outer.entry(0).entry(0).asString());
    assertEquals(0, outer.entry(0).entry(1).asLong());
    assertEquals(3, outer.entry(1).entryCount());
    assertEquals("c2", outer.entry(1).entry(0).asString());
    assertEquals(2, outer.entry(1).entry(1).asLong());
    assertEquals(3, outer.entry(1).entry(2).asLong());
    assertEquals(4, outer.entry(2).entryCount());
    assertEquals("c3", outer.entry(2).entry(0).asString());
    assertEquals(3, outer.entry(2).entry(1).asLong());
    assertEquals(4, outer.entry(2).entry(2).asLong());
    assertEquals(5, outer.entry(2).entry(3).asLong());
    assertEquals(5, outer.entry(3).entryCount());
    assertEquals("c4", outer.entry(3).entry(0).asString());
    assertEquals(4, outer.entry(3).entry(1).asLong());
    assertEquals(5, outer.entry(3).entry(2).asLong());
    assertEquals(6, outer.entry(3).entry(3).asLong());
    assertEquals(7, outer.entry(3).entry(4).asLong());
}
Also used : Inspector(com.yahoo.data.access.Inspector) JSONString(com.yahoo.prelude.hitfield.JSONString) JSONString(com.yahoo.prelude.hitfield.JSONString) Test(org.junit.Test)

Aggregations

Inspector (com.yahoo.data.access.Inspector)21 Test (org.junit.Test)19 JSONString (com.yahoo.prelude.hitfield.JSONString)8 Value (com.yahoo.data.access.simple.Value)6 SlimeAdapter (com.yahoo.data.access.slime.SlimeAdapter)1 Slime (com.yahoo.slime.Slime)1 ByteBuffer (java.nio.ByteBuffer)1