Service Virtualization

Expand all | Collapse all

What Steps Return JSON objects/arrays (JSON Path) ?

  • 1.  What Steps Return JSON objects/arrays (JSON Path) ?

    Posted 08-26-2015 05:11 PM

    All -

     

      I was looking at the documentation for JSON Assertions and was curious as to what steps in a virtual service model can you use the JSON Path assertions?  The docs say that JSON Assertions can be used for ANY step, but I can't seem to find any guidance on how you can get any VSM Step to return JSON objects/arrays.

     

      Can anyone offer any guidance ?

     

    Thanks,

    Jeff



  • 2.  Re: What Steps Return JSON objects/arrays (JSON Path) ?

    Broadcom Employee
    Posted 08-26-2015 06:26 PM

    Do you need to extract the result using JSON path from a JSON String?

    If so please refer to the following link.

     

    https://wiki.ca.com/display/DTS80/JSON+Path+Filter



  • 3.  Re: What Steps Return JSON objects/arrays (JSON Path) ?

    Posted 08-27-2015 10:09 AM

    Prem -

     

      I was more or less just trying to figure out how to use the JSON Assertions in a Virtual Service Model.  I'm assuming that in order for you to use JSON Path to extract/verify JSON objects, that the step must return JSON.  So I'm just trying to figure out how you can have a step that returns JSON.



  • 4.  Re: What Steps Return JSON objects/arrays (JSON Path) ?

    Posted 08-27-2015 11:13 AM

    More specifically, in these instructions it says, " lets you ensure that a JSON Path result that is either a JSON object or a JSON array contains any or all of the values in a specified list", but what actual object is the JSON Path actually searching through?  I don't see where you define the object to be searched.

     

    In the docs for the JSON Path Filter, it allows you to define the property to search in, but how do you do that for the JSON Assertions?



  • 5.  Re: What Steps Return JSON objects/arrays (JSON Path) ?

    Posted 08-27-2015 07:26 PM

    there are only three JSON assertions

     

    (step) Result equals  = whole result matches

    (step) Result contains = some part of result matches

    ensure schema

     

    schema you can select where the data is (payload)  and where the schema data is

    jsonschema.jpg

     

    json path is a different animal.,

     

    there you can carve out a piece of the json content from a property

    and put it somewhere else..

     

    I find test steps to be the easiest way to set this up..

     

    run thru this step then look at the properties, then the json path navigation will work



  • 6.  Re: What Steps Return JSON objects/arrays (JSON Path) ?

    Posted 12-01-2017 07:14 AM

    It would be of a great help if you can help me with the below query.

    When you want to have JSON assertion we should specify the index of the array in the JSON Xpath. For Example.
    data[
    { "id": 2,
    "name": "An ice sculpture",
    "price": 12.50,
    "tags": ["cold", "ice"],
    "dimensions": {
    "length": 7.0,
    "width": 12.0 },
    "warehouseLocation": {
    "latitude": -78.75
    }
    }
    ]

    then we will give the xpath as "$.data[0].name" which will return the value as " An ice sculpture". Now i have an requirement where in the json response is below.

    data[
    { "id": 2,
    "name": "An ice sculpture",
    "price": 12.50,
    "tags": ["cold", "ice"],
    "dimensions": {
    "length": 7.0,
    "width": 12.0 },
    "warehouseLocation": {
    "latitude": -78.75
    }
    }

    { "id": 3,
    "name": "An ice sculpture1",
    "price": 12.50,
    "tags": ["cold", "ice"],
    "dimensions": {
    "length": 7.0,
    "width": 12.0 },
    "warehouseLocation": {
    "latitude": -78.75
    }
    }
    ]

    now i want both of these values to be verified, how do we do this in DevTest tool ?