2016-11-05 77 views
0

單個對象檢索JSON數據下面給出的JSON:使用JSONPath

我可以用
{ 
    "store": { 
     "book": [ 
      { 
       "category": "reference", 
       "author": "Nigel Rees", 
       "title": "Sayings of the Century" 
      }, 
      { 
       "category": "fiction", 
       "author": "Evelyn Waugh", 
       "title": "Sword of Honour", 
       "price": 12.99 
      }, 
      { 
       "category": "fiction", 
       "author": "Herman Melville", 
       "title": "Moby Dick", 
       "isbn": "0-553-21311-3" 
      }, 
      { 
       "category": "fiction", 
       "author": "J. R. R. Tolkien", 
       "title": null, 
       "isbn": "0-395-19395-8", 
       "price": null 
      } 
     ], 
     "bicycle": { 
      "color": "red", 
      "price": 19.95 
     } 
    }, 
    "expensive": 10 
} 

什麼JSON路徑檢索包含categoryauthorpricetitle參數book的第一個元素?要清楚,我不想任何category,author,0 pricetitle參數 - 只有那些來自單個書籍對象的參數。此外,book數組的結構也不盡相同(即其元素的數量和配置隨時間而改變),所以我無法真正對任何內容進行硬編碼。

回答

0

我想你的意思是你想:

$ ..書[?(@類& & @ .author & & @。價格& & @ .title僞)

+0

我想在這裏: https://jsonpath.curiousconcept.com/。無法讓它工作 – Adam