@Test
public void testBson () throws IOException
{
BasicConfigurator.configure ();
String f = "../tests/data/data1.bson";
File file = new File (f.replace ('/', File.separatorChar));
JsonPathProvider provider = new JsonPathProvider ();
Configuration pathConfig = Configuration.defaultConfiguration ().jsonProvider (provider);
JsonPath path = JsonPath.compile ("$..A");
JsonProvider p = new CookJsonProvider ();
HashMap<String, Object> readConfig = new HashMap<String, Object> ();
readConfig.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
readConfig.put (CookJsonProvider.ROOT_AS_ARRAY, Boolean.TRUE);
JsonReaderFactory rf = p.createReaderFactory (readConfig);
JsonReader reader = rf.createReader (new FileInputStream (file));
JsonStructure obj = reader.read ();
reader.close ();
JsonValue value = path.read (obj, pathConfig);
Assert.assertEquals ("[1,3,5,7]", provider.toJson (value));
}
JsonPathProviderTest.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:cookjson
作者:
评论列表
文章目录