Service Virtualization

Expand all | Collapse all

Handling JSON Mandatory elements inside optional Array.

Jump to Best Answer
  • 1.  Handling JSON Mandatory elements inside optional Array.

    Posted 11-12-2018 05:29 AM

    Hi Team,

     

    I am working on one of the stub in which i need to handle below cases. Please suggest how to handle this type of scenarios.

     

    • Optional array(repetitive) is there, if optional array is not passing, success response should sent.
    • If Optional array is passing, few elements inside optional array are mandatory. that needs to validated
    • Passing mandatory and optional fields----Success Response.
    • Passing mandatory fields , optional array without mandatory fields----Bad Request.



  • 2.  Re: Handling JSON Mandatory elements inside optional Array.

    Posted 11-12-2018 01:06 PM

    What version of DevTest are you using? is there a sample you can share?



  • 3.  Re: Handling JSON Mandatory elements inside optional Array.

    Posted 11-13-2018 02:23 AM

    I am using Dev Test version 10.0.

     

    Sample Array structure looks like this:

    {

       "a": {

             "b": " ",

             "c": " ",

             "I2I":  {

                   "d.1": " ",

                   "d.2": {

                         "Item": {

                                  "e.1": " ",

                                  "e.2": " ",

                                  "I2I": {

                                           "d.1": " ",

                                           "d.2": {                        

                                                   "Item": {

                                                             "e.1": " ",

                                                               "e.2": " ",

                      }

    }

    }
    }

    }

    }

    }

    }

     

    Above Highlighted Array Blocks ie., I2I(Item to Item) Array and Item Array are repetitive.

     

    Please let me know if you need more information.

                                           



  • 4.  Re: Handling JSON Mandatory elements inside optional Array.
    Best Answer

    Posted 11-14-2018 06:43 AM

    Hi

    Refer this - An Approach for virtualizing optional repeating blocks 

     

    hope this will help.