Forum Discussion

Sandyapitester's avatar
Sandyapitester
Frequent Contributor
8 years ago
Solved

API Automation jsonpath node issue

Hi All

 

SOAPUI PRO

 

API response has

[ { "username": "xyz", "password": "1234",

},

{ "username": "null", "password": "12344", },

{ "username": "AB1", "password": "123411", },

{ "username": "null", "password": "1234111", },

  {
  "username": "null",
  "password": "123",

} ]

Json node

JSON

• 0

• 1 

• 2 

• 3 

• 4

 

Now am trying to get the username from all the record which should not null

$.[*].[?(@.username)] And $..[?(@.username)]

Both assertion is not working

 

Guide me if u have a solution

  • Sandyapitester's avatar
    Sandyapitester
    8 years ago

    Hi Bro,

     

    ur right it's  a typo error. thanks for the information and great support

     

     

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Your JSON is not valid -- it has extra commas before }. Assuming these are just typos, the following should work:

    $[?(@.username != "null")].username 
    • Sandyapitester's avatar
      Sandyapitester
      Frequent Contributor

      Hi Bro,

       

      Extra commas before }. is not a typo error. that the way getting the response.

       

      I tired with the below assertion

       

      $[?(@.username != "null")].username 

       

      It's not working.. any other way to fix this issue

       

       

      • Sandyapitester's avatar
        Sandyapitester
        Frequent Contributor

        Hi Bro,

         

        ur right it's  a typo error. thanks for the information and great support