Service Virtualization

Expand all | Collapse all

REST Virtualization with complex JSON Payload

  • 1.  REST Virtualization with complex JSON Payload

    Posted 11-01-2017 09:43 PM

    monika_mehta

     

    I need to do the REST virtualization with RR pairs. The request file is as follows:

     

    POST /air-shopping/carInsurance.action HTTP/1.1
    Content-Type: application/x-www-form-urlencoded

     

    {"carJson":"{"carDesc":{"carModel":"Honda","isBlack":false,"hasInsurance":false},"accidentsInfo":[{"accidentCount":"1","accidentTypeCode":"MINOR"}],"bundled":false,"searchType":"SEARCH","appName":"CAR-INS","shopPreferenceType":"PRICE","filterSearch":false,"searchedSlices":[{"date":"2017-11-01","origin":{"code":"ATL"},"destination":{"code":"MSP"}}],"carType":"USED","loggedIn":false,"requestedPageNumber":1,"currentSliceIndex":"0","refundable":false,"shopType":"REVENUE","fareFamily":"BE","sortCriteria":{"selectedSortType":"customScore"}}","sellerId":"carInsurance","buyerId":"carInsurance","otherId":"carInsurance"}

     

    It has a Json structure payload which can be simplified as below, for better understanding:

    {carJson:{SomeChildJson}

    sellerId:carInsurance

    buyerId:carInsurance

    otherId:carInsurance}

     

    My requirement is that, I should be able to set the independent key value pairs inside the {SomeChildJson} as the arguments for the VSI, so that the incoming requests can be identified uniquely and respective responses can be sent.

     

    How do I do it? What data protocols to use to break it into separate arguments?@@@@@



  • 2.  Re: REST Virtualization with complex JSON Payload

    Posted 11-02-2017 03:58 AM

    Hi Malikaarjun, 

    As I understand from your question you want to identify the each JSON element individual key value pair in your VS Image file and you will apply the comparison based on some value i.e.  sellerId 

     

    JSON reqquest you have shared is not in proper JSON format. I have corrected it and created a VS by using the same request and I can see every element individually in my VS. 

    Correct JSON request :-

     

    {
    "carJson":{
    "carDesc":{
    "carModel":"Honda",
    "isBlack":false,
    "hasInsurance":false
    },
    "accidentsInfo":[
    {
    "accidentCount":"1",
    "accidentTypeCode":"MINOR"
    }
    ],
    "bundled":false,
    "searchType":"SEARCH",
    "appName":"CAR-INS",
    "shopPreferenceType":"PRICE",
    "filterSearch":false,
    "searchedSlices":[
    {
    "date":"2017-11-01",
    "origin":{
    "code":"ATL"
    },
    "destination":{
    "code":"MSP"
    }
    }
    ],
    "carType":"USED",
    "loggedIn":false,
    "requestedPageNumber":1,
    "currentSliceIndex":"0",
    "refundable":false,
    "shopType":"REVENUE",
    "fareFamily":"BE",
    "sortCriteria":{
    "selectedSortType":"customScore"
    }
    },
    "sellerId":"carInsurance",
    "buyerId":"carInsurance",
    "otherId":"carInsurance"
    }

    My VSI look like as below 

     

     

     

    Here I can see every element individual and apply the comparison operator as per the need.