1

I am validating output of the GET request with the data stored in the ms sql table using jdbc connection.

I would like to achieve below.

Output of my get request is like below

[

{
    "Id1": "9f3da555-136b-461d-a6d6-575c61599896",
    "Id2": "96135439-17f5-424c-9285-fc672b0626ac",
    "Id3": "da2e6593-381b-452b-9879-e61f5b97f97b",
    "Name": "abc",
    "name2": "xyz"
},

{
    "Id4": "9f3da555-136b-461d-a6d6-575c61599896",
    "Id5": "96135439-17f5-424c-9285-fc672b0626ac",
    "Id6": "da2e6593-381b-452b-9879-e61f5b97f97b",
    "Name": "abc1",
    "name2": "xyz1",
    "productName":"Amazon",
    "ProductFamily":"Mobile"
},
{
    "Id7": "9f3da555-136b-461d-a6d6-575c61599896",
    "Id8": "96135439-17f5-424c-9285-fc672b0626ac",
    "Id9": "da2e6593-381b-452b-9879-e61f5b97f97b",
    "Name": "abc3",
    "name2": "xyz3",
    "productName":"Amazon",
    "location":"India"
    }
    .............}

But my query output is

[

{ "Id1": "9f3da555-136b-461d-a6d6-575c61599896", "Id2": "96135439-17f5-424c-9285-fc672b0626ac", "Id3": "da2e6593-381b-452b-9879-e61f5b97f97b", "Name": "abc", "name2": "xyz" "productName":null, "ProductFamily":null, "location":null }, {

    "Id4": "9f3da555-136b-461d-a6d6-575c61599896",
    "Id5": "96135439-17f5-424c-9285-fc672b0626ac",
    "Id6": "da2e6593-381b-452b-9879-e61f5b97f97b",
    "Name": "abc1",
    "name2": "xyz1",
    "productName":"Amazon",
    "ProductFamily":"Mobile",
    "location": null
},
{
    "Id7": "9f3da555-136b-461d-a6d6-575c61599896",
    "Id8": "96135439-17f5-424c-9285-fc672b0626ac",
    "Id9": "da2e6593-381b-452b-9879-e61f5b97f97b",
    "Name": "abc3",
    "name2": "xyz3",
    "productName":"Amazon",
    "productFamily":null,
    "location":"India"
    }
    .............}  

So I am looking for a solution where I can add ProductName, ProductFamily and location in the output of GET API call with value as null if the kay is not present in the object but if it is present like shown above in one of the json object then it should not change that value.

Can someone please guide me.

  • ALL the information you need to solve is present in the linked question. if you are still stuck, please simplify your JSON and ask a new question, and explain what you have tried. and please make sure you use well-formed JSON: https://stackoverflow.com/help/minimal-reproducible-example – Peter Thomas Feb 12 '21 at 11:20
  • @PeterThomas I checked the linked question but looks like my question is different, I would like to add new key with null values based on condition into the dynamic response body. – Pankaj Nalawade Feb 12 '21 at 12:25
  • I have nothing to add to my previous comment – Peter Thomas Feb 12 '21 at 13:17

0 Answers0