Skip to content

Instantly share code, notes, and snippets.

@takawitter
Last active December 23, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takawitter/6684644 to your computer and use it in GitHub Desktop.
Save takawitter/6684644 to your computer and use it in GitHub Desktop.
import net.arnx.jsonic.JSON;
import org.jsonman.Node;
import org.jsonman.NodeFactory;
import org.jsonman.NodeFinder;
import org.jsonman.node.MapNode;
import org.junit.Assert;
import org.junit.Test;
public class NodeFinderTest{
@Test
public void test_4() throws Exception{
Node src = NodeFactory.create(JSON.decode(
"{\"people\":[{\"name\":\"john\",\"age\":20}," +
"{\"name\":\"bob\",\"age\":30}]}"
));
new NodeFinder(src).find("/people[name=bob]", (path, node) -> {
Assert.assertTrue(node.isMap());
MapNode mn = node.cast();
Assert.assertEquals("bob", mn.getChildValue("name"));
Assert.assertEquals(30, ((Number)mn.getChildValue("age")).intValue());
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment