Service Virtualization

Expand all | Collapse all

Need to generate dynamic JSON response

Jump to Best Answer
  • 1.  Need to generate dynamic JSON response

    Posted 02-21-2018 07:25 PM

    I am creating a VS which saves an array of values in a filter and then asynchronously it needs to send a dynamic response. Example: filter_orderItem_id : ["ON0001","ON0002,"ON0003","ON0004"]

    I need to insert the values into 4 new rows along with timestamp Later on, a test case will fetch all the records based on time-stamp and send individual responses as below:


    "event": "statusNotification",

    "OrderId": "ON0001",

    "Timestamp": "20-02-2018"


    { "event": "statusNotification",

    "OrderId": "ON0002",

    "Timestamp": "20-02-2018"


  • 2.  Re: Need to generate dynamic JSON response
    Best Answer

    Posted 05-02-2018 07:32 AM

    I have done this thing for SOAP where XML can be dynamically formed easily using properties and other supported steps like response lookup, Parse Text as response . I am not sure but we can convert response from JSON to XML or vice-Versa and then play around to make changes . Once you have your array values (Property)  embedded you can convert the same into JSON and save it in DB with Timestamp. 


    For sending Responses : You can create a test case that will pick up responses from DB according to timestamp or you can have a delay/Wait time column as well in same table using which responses can be sent setting different wait time