JsonPathProviderTest.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:cookjson 作者:
@Test
public void testParseString () throws IOException
{
    BasicConfigurator.configure ();
    String f = "../tests/data/complex1.json";
    File file = new File (f.replace ('/', File.separatorChar));
    String str = Utils.getString (file);

    JsonPathProvider provider = new JsonPathProvider ();

    Configuration pathConfig = Configuration.defaultConfiguration ().jsonProvider (provider);
    JsonPath path = JsonPath.compile ("$.strange");
    JsonValue value = path.read (str, pathConfig);

    // we cannot directly compare the output since the attribute ordering
    // can vary.
    Assert.assertEquals ("{\"id\":5555,\"price\":[1,2,3],\"customer\":\"john...\"}".length (), provider.toJson (value).length ());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号