jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: JSON
Date Tue, 05 Jan 2016 16:44:23 GMT
Hi
one more question - what is the library you are using to parse the JSON (or
what are the imports in your beanshell script?)

regards
deepak

On Tue, Jan 5, 2016 at 2:33 AM, Erez Naim <Erez@theneura.com> wrote:

> Hi Deepak,
>
> This is my JSON:
>
>
> {"status":"success","timestamp":1451989824,"data":{"currentSituation":{"situation":"place","locationData":{"name":"home","label":"home"}},"transit":{"situation":"driving"},"previousPlace":{"situation":"place","locationData":{"name":"home","label":"home"}}}}
>
> As you can see sometimes the last attribute ("next") is not displayed so I
> am getting null error which I cannot retrieve and for that I am getting an
> error and cannot continue...
>
> BR,
>
> Erez Naim  |  QA Lead  |
>
> EL AL 2 Street | Herzliya
> mobile (+972) 50 9 555 686 | fax (408) 689.1366 | skype erez.neura
>
> website  |  blog  |  twitter  |  map
>
>
> -----Original Message-----
> From: Deepak Shetty [mailto:shettyd@gmail.com]
> Sent: Monday, January 4, 2016 6:17 PM
> To: JMeter Users List <user@jmeter.apache.org>
> Subject: Re: JSON
>
> Hi
> what does your JSON string look like and what error are you getting ? Post
> processor errors do not usually terminate the script.
>
> >  generateCSVfile(writer,sFileName,timestamp,currentSituation,transit,
> previousPlace,next);
> Unless this function is coded carefully , the above isnt a good idea.
>
> On Mon, Jan 4, 2016 at 7:41 AM, Erez Naim <Erez@theneura.com> wrote:
>
> > Hi all,
> >
> >
> >
> > I am using BeanshellPostProcessor in order to parse json response from
> > the server…
> >
> >
> >
> > I am getting into a problem where if a null response is returned from
> > the server it terminate the program, this is my program: my problem is
> > when it getting to the point where the "if" statement is, it just
> > terminate the program and returing an error, I have tried doing it on
> > eclipse it worked here for some reason it does not let the program to
> > continue and to get null values.
> >
> >
> >
> > String jsonString = prev.getResponseDataAsString();
> >
> > JSONObject responseJSON = new JSONObject(jsonString);
> >
> > data = responseJSON.get("data");
> >
> >
> >
> > try{
> >
> >                 //getting all current situation data info
> >
> >                 currentSituation =
> > (JSONObject)data.getJSONObject("currentSituation");
> >
> >
> >
> >                 //getting all transit data info
> >
> >                 transit =
> > (JSONObject)data.get("transit");
> >
> >
> >
> >                 //getting all previous location data info
> >
> >                 previousPlace =
> > (JSONObject)data.getJSONObject("previousPlace");
> >
> >
> >
> >                 //getting all next data info
> >
> >                 if(((JSONObject)data.get("next")!=null)){
> >
> >                                 next =
> > (JSONObject)data.getJSONObject("next");
> >
> >                 }else{
> >
> >                                 System.out.println("got here");
> >
> >                                 next=null;
> >
> >                 }
> >
> >
> >
> >                 System.out.println("generating csv file...");
> >
> >
> > generateCSVfile(writer,sFileName,timestamp,currentSituation,transit,
> > previousPlace,next);
> >
> >
> >
> >                 //System.out.println("next situation is: " + next);
> >
> >
> >
> >
> >
> > }catch (Exception ex){
> >
> >     log.warn("Error in my script, probably data is null", ex);
> >
> >     throw ex; // elsewise JMeter will "swallow" the above exception
> >
> > }
> >
> >
> >
> > Erez Naim  |  QA Lead  |
> >
> > [image: cid:image004.png@01D01E1B.5F153500]
> >
> > EL AL 2 Street | Herzliya
> > mobile (+972) 50 9 555 686 | fax (408) 689.1366 | skype erez.neura
> >
> >
> >
> > website <http://www.theneura.com/>  |  blog
> > <http://www.startupbitz.com/>  |  twitter
> > <https://twitter.com/intent/user?screen_name=theneura>  |  map
> > <http://goo.gl/maps/ZRkg5>
> >
> >
> >
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message