0
我想使用com.jayway.jsonpath.JsonPath从JSON字符串读取键/值:com.jayway.jsonpath.JsonPath找不到钥匙
String contentAsString = mvcResult.getResponse().getContentAsString();
System.out.println(contentAsString);
Object value = JsonPath.read(contentAsString, "$.key");
但我得到的错误:
Expected to find an object with property ['key'] in path $ but found 'net.minidev.json.JSONArray'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
印刷contentAsString
给出:
[{"firstName":"N","key":"mykey"}]
是contentAsString
无效的JSON?