How to capture JSON item using selenium API

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to capture JSON item using selenium API

azeddin.margani
Hi , 
Can someone assist?.  I need to capture an item within JSON response displayed in eclipse/selenium console. The JOSN file looks as follows:
 
{
   "ID" : "28821b78-e7cda408-35e37-91ee8a7b-a34464df",
   "IsStable" : true,
   "LastUpdate" : "2017",
   "MainDicomTags" : {
      "PatientBirthDate" : "19331111",
      "PatientID" : "0092124",
      "PatientName" : "Oneby^^",
      "PatientSex" : "O"
   },
   "Studies" : [ "9cc51d8b-93b25cf5-6a1ab08d" ],
   "Type" : "Patient"
}
The item I want to capture is: PatientID 
My intended code is below but not getting the desired item: PatientID.
RestAssured.baseURI = "http://XXXXXX";
  RequestSpecification httpRequest = RestAssured.given();
   Response response = httpRequest.get("/2c1e37-91ee8a7b-a34464df");
       JsonPath json = response.jsonPath();
            String responseBody = response.getBody().asString();
//put into Array
               JSONArray MainDicomTags= (JSONArray)json.get("MainDicomTags");
                     for(int i=0; i<MainDicomTags.size(); i++){
      
                        System.out.println("The " + i + " element of the array: "+MainDicomTags.get(i));
       
                    } 
Thanks, 
AM.
                    
           
       

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/13a69327-9ad3-4f54-9b45-fdc320969f68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to capture JSON item using selenium API

Yogesh Khachane

You can use for this scenario regular expression it will return u exact json objects whatever u want.

On 25 May 2018 18:25, <[hidden email]> wrote:
Hi , 
Can someone assist?.  I need to capture an item within JSON response displayed in eclipse/selenium console. The JOSN file looks as follows:
 
{
   "ID" : "28821b78-e7cda408-35e37-91ee8a7b-a34464df",
   "IsStable" : true,
   "LastUpdate" : "2017",
   "MainDicomTags" : {
      "PatientBirthDate" : "19331111",
      "PatientID" : "0092124",
      "PatientName" : "Oneby^^",
      "PatientSex" : "O"
   },
   "Studies" : [ "9cc51d8b-93b25cf5-6a1ab08d" ],
   "Type" : "Patient"
}
The item I want to capture is: PatientID 
My intended code is below but not getting the desired item: PatientID.
RestAssured.baseURI = "http://XXXXXX";
  RequestSpecification httpRequest = RestAssured.given();
   Response response = httpRequest.get("/2c1e37-91ee8a7b-a34464df");
       JsonPath json = response.jsonPath();
            String responseBody = response.getBody().asString();
//put into Array
               JSONArray MainDicomTags= (JSONArray)json.get("MainDicomTags");
                     for(int i=0; i<MainDicomTags.size(); i++){
      
                        System.out.println("The " + i + " element of the array: "+MainDicomTags.get(i));
       
                    } 
Thanks, 
AM.
                    
           
       

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/13a69327-9ad3-4f54-9b45-fdc320969f68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAJOfxvNKLN1qc%3DtM50N2YyCCJejOeeBJfhe2-C0L1GA%3DymvWeA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to capture JSON item using selenium API

azeddin.margani
Hi Yogesh - can you please elaborate more on to your answer?. 
Thanks.

On Friday, May 25, 2018 at 2:34:40 PM UTC+1, Yogesh Khachane wrote:

You can use for this scenario regular expression it will return u exact json objects whatever u want.

On 25 May 2018 18:25, <<a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="Z0KGwUdqDAAJ">azeddin...@...> wrote:
Hi , 
Can someone assist?.  I need to capture an item within JSON response displayed in eclipse/selenium console. The JOSN file looks as follows:
 
{
   "ID" : "28821b78-e7cda408-35e37-91ee8a7b-a34464df",
   "IsStable" : true,
   "LastUpdate" : "2017",
   "MainDicomTags" : {
      "PatientBirthDate" : "19331111",
      "PatientID" : "0092124",
      "PatientName" : "Oneby^^",
      "PatientSex" : "O"
   },
   "Studies" : [ "9cc51d8b-93b25cf5-6a1ab08d" ],
   "Type" : "Patient"
}
The item I want to capture is: PatientID 
My intended code is below but not getting the desired item: PatientID.
RestAssured.baseURI = "<a onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FXXXXXX\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEFfsqEpnjJRoEQ8sPWsIoSPFWOGg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FXXXXXX\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEFfsqEpnjJRoEQ8sPWsIoSPFWOGg&#39;;return true;" href="http://XXXXXX" target="_blank" rel="nofollow">http://XXXXXX";
  RequestSpecification httpRequest = RestAssured.given();
   Response response = httpRequest.get("/2c1e37-91ee8a7b-a34464df");
       JsonPath json = response.jsonPath();
            String responseBody = response.getBody().asString();
//put into Array
               JSONArray MainDicomTags= (JSONArray)json.get("MainDicomTags");
                     for(int i=0; i<MainDicomTags.size(); i++){
      
                        System.out.println("The " + i + " element of the array: "+MainDicomTags.get(i));
       
                    } 
Thanks, 
AM.
                    
           
       

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="Z0KGwUdqDAAJ">selenium-user...@googlegroups.com.
To post to this group, send email to <a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="Z0KGwUdqDAAJ">seleniu...@googlegroups.com.
To view this discussion on the web visit <a onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/13a69327-9ad3-4f54-9b45-fdc320969f68%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/13a69327-9ad3-4f54-9b45-fdc320969f68%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" href="https://groups.google.com/d/msgid/selenium-users/13a69327-9ad3-4f54-9b45-fdc320969f68%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow">https://groups.google.com/d/msgid/selenium-users/13a69327-9ad3-4f54-9b45-fdc320969f68%40googlegroups.com.
For more options, visit <a onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" href="https://groups.google.com/d/optout" target="_blank" rel="nofollow">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/251731c9-1e82-4fc5-95f5-a4990becd680%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.