2015-02-10 39 views
1

我想從membershipId的下方只有一個提取所有OFFERID的:JSONPath提取值

{ 
    "resultCode": "SUCCESS", 
    "errorCode": null, 
    "errorMessage": null, 
    "membershipCoupons": 
    [ 
     { 
      "membershipId": "32021428", 
      "coupons": 
      [ 
       { 
        "offerId": "000C291EE8241ED4AAF43058D8564910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D8564910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D8564910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": 1423579699407, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D857A910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D857A910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D857A910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": 1423579703400, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D8608910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D8608910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D8608910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": 1423579706707, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D862E910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D862E910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D862E910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": 1423579710047, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D87A0910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87A0910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87A0910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": 1423579713540, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D877E910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D877E910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D877E910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": 1423579717533, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D87B8910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87B8910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87B8910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": 1423579721123, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D8870910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D8870910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D8870910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": 1423579724430, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C297765971EE4A8C22C6999219BA4", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201504_003/000C297765971EE4A8C22C6999219BA4Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201504_003/000C297765971EE4A8C22C6999219BA4High.jpg" 
         } 
        ], 
        "endTime": 1425168000000, 
        "activationDate": 1423136616203, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C297765971EE4A8C22C699921FBA4", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201504_003/000C297765971EE4A8C22C699921FBA4Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201504_003/000C297765971EE4A8C22C699921FBA4High.jpg" 
         } 
        ], 
        "endTime": 1425168000000, 
        "activationDate": 1423139501440, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C297765971EE4A8C22C6999233BA4", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201504_003/000C297765971EE4A8C22C6999233BA4Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201504_003/000C297765971EE4A8C22C6999233BA4High.jpg" 
         } 
        ], 
        "endTime": 1425168000000, 
        "activationDate": 1423215586673, 
        "redemption": null 
       } 
      ] 
     }, 
     { 
      "membershipId": "8315319211", 
      "coupons": 
      [ 
       { 
        "offerId": "000C291EE8241ED4AAF43058D85CA910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D85CA910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D85CA910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": null, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D85F6910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D85F6910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D85F6910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": null, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D85E2910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D85E2910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D85E2910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": null, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D85FC910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D85FC910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D85FC910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": null, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D8776910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D8776910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D8776910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": null, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D87A8910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87A8910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87A8910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": null, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D87B6910", 
        "description": "nora", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87B6910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87B6910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": null, 
        "redemption": null 
       }, 
       { 
        "offerId": "000C291EE8241ED4AAF43058D87D0910", 
        "description": "nora.", 
        "graphics": 
        [ 
         { 
          "width": 400, 
          "height": 200, 
          "quality": "Low", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87D0910Low.jpg" 
         }, 
         { 
          "width": 900, 
          "height": 600, 
          "quality": "High", 
          "url": "https://site/02_201506_011/000C291EE8241ED4AAF43058D87D0910High.jpg" 
         } 
        ], 
        "endTime": 1423353600000, 
        "activationDate": null, 
        "redemption": null 
       } 
      ] 
     } 
    ] 
} 

我有東西兩個MEMBERID的作品,但我想參數,這樣我只挑了OFFERID的一個參數我有一個會議,我通常會參考這個$ {medlem},我使用Scala。

這工作:

.check(jsonPath("$.membershipCoupons[*].coupons[?(@.activationDate==null)].offerId").findAll.optional.saveAs("itemList")) 

但我怎麼能說這與參數指向特定MEMBERID是這樣的:

 .check(jsonPath("$.membershipCoupons[membershipId[${medlem}]].coupons[?(@.activationDate==null)].offerId").findAll.optional.saveAs("itemList")) 

回答

0

我認爲你需要2個階段拆分操作:

arrayMembershipId = $.membershipCoupons[*].membershipId 
n = getIndex(membershipIdArray, yourcode) 
arrayOffer = membershipCoupons[n].coupons[?(@.activationDate==null)].offerId