我有这个 Json :
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"fl":"solr_url, solr_date",
"indent":"true",
"q":"solr_body:party",
"wt":"json"}},
"response":{"numFound":19,"start":0,"docs":[
{
"solr_date":"2013-06-19T13:48:02Z",
"solr_url":["http://blogs.economictimes.indiatimes.com/urbanissues"]},
{
"solr_date":"2013-07-27T13:48:02Z",
"solr_url":["http://blogs.economictimes.indiatimes.com/outsideedge"]},
{
"solr_date":"2013-07-27T13:48:02Z",
"solr_url":["http://blogs.economictimes.indiatimes.com/outsideedge/entry/in-defense-of-advani"]},
{
"solr_date":"2013-07-25T13:48:02Z",
"solr_url":["http://blogs.economictimes.indiatimes.com/serendipity"]},
{
"solr_date":"2013-07-26T13:48:02Z",
"solr_url":["http://blogs.economictimes.indiatimes.com/Ragtime"]},
{
"solr_date":"2013-07-24T13:48:02Z",
"solr_url":["http://blogs.economictimes.indiatimes.com/SilkStalkings"]},
{
"solr_date":"2013-07-28T13:48:02Z",
"solr_url":["http://blogs.economictimes.indiatimes.com/RaisinaWatch"]},
{
"solr_date":"2013-07-25T13:48:02Z",
"solr_url":["http://blogs.economictimes.indiatimes.com/Cursor/entry/the-unbearable-lightness-of-advani-s-rebellion"]},
{
"solr_date":"2013-07-30T13:48:02Z",
"solr_url":["http://blogs.reuters.com/great-debate/2013/06/17/the-real-irs-scandal/"]},
{
"solr_date":"2013-07-29T13:48:02Z",
"solr_url":["http://blogs.reuters.com/johncabell"]}]
}}
我正在使用杰克逊进行解析。现在的问题是我想根据 solr_date 选择 solr_url。这在 DOM 解析中听起来很简单,但在 Json 中很难做到。假设日期大于 7 月 18 日(我已经完成了日期逻辑)选择 solr_url。你能帮我解决这个问题吗?
ObjectMapper mapper = new ObjectMapper();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
JsonNode node = mapper.readTree(new URL("json output url"));