Re: [rest-assured] Extracting elements from the response

175 views
Skip to first unread message
Message has been deleted

Johan Haleby

unread,
Jan 6, 2018, 9:25:04 AM1/6/18
to rest-a...@googlegroups.com
You would have to either create a DTO containing the two fields you're interested in or extract "events" to a List of Map's and then (programmatically, i.e. using vanilla Java) extract the fields you're interested in.

On Fri, Jan 5, 2018 at 7:18 PM, Sanju <java.se...@gmail.com> wrote:

Hi,

I have a question about the below response.

Generally if I have to extract just one element, I do like this.

boolean isJoin =  Response.then()
                                                                 .contentType(ContentType.JSON) // 
                     .extract().path("responseType").equals("JOIN");

Now my requirement is I would need to extract participantId for the eventType "MEETING_JOINED" and name "b"

Could you please help in this one?

"lastSeqNum": 47727,

    "events": [
        {
            "eventType": "MEETING_STARTED",
            "timestamp": "2018-01-04T19:21:11.440Z",
            
        },
        {
            "eventType": "MEETING_JOINED",
            "timestamp": "2018-01-04T19:21:11.640Z",
            "participantId": "d9ivt8n6st6wk5fphbway9b2s",
            "name": "b",
            
        },
        {
            "eventType": "CONTENT_CREATED",
            "timestamp": "2018-01-04T19:21:11.655Z",
            
        },
        {
            "eventType": "AUDIO_MEETING_STARTED",
            "timestamp": "2018-01-04T19:21:12.438Z"
        },
        {
            "eventType": "MEETING_JOINED",
            "timestamp": "2018-01-04T19:26:47.705Z",
            "participantId": "j2szhbsmc58laqe3r6nrttre",
            "name": "a",
            
        }

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages