djangid / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Question about path parsing #65

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi

Could u provide some excamples how to access fields in JSON like that:

[ 
    {
        id: 1
        name: "name"
        originalName: "origName"
        year: 2011
    }, {
        id: 2
        name: "name2"
        originalName: "origName2"
        year: 2010
    }
]

Very grateful

Original issue reported on code.google.com by Azazel....@gmail.com on 28 Apr 2011 at 2:41

GoogleCodeExporter commented 8 years ago
I've resolve my problem :) Thx

.body( "get(0).name", equalTo( "name" ) )

Original comment by Azazel....@gmail.com on 29 Apr 2011 at 8:09

GoogleCodeExporter commented 8 years ago
Exactly. I think you can do 

.body( "[0].name", equalTo("name") ) 

as well. Or if yo want to verify both names in the same expression:

.body( "name", hasItems("name", "name2") )

Thanks for using REST Assured (remember that you can also use the mailing-list 
if you need any further support)

Original comment by johan.ha...@gmail.com on 2 May 2011 at 6:27