You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Kai Kaisen <ka...@googlemail.com> on 2011/03/21 19:57:58 UTC

Write and Read javascript arrays in BSF Processors

Hi guys,
I have a questions regarding javascript arrays. Can they be stored as
'global variables' in jmeter?

I have a BSF PostProcessor parsing a JSON response and storing data in an
javascript array:
  var prodArray= new Array();
  ...
  prodArray.push(prodWorkspaceName);
  ...

This array gets put to jmeter variables:
  vars.put("prodArray", prodArray);

Now, in another BSF PreProcessor I want to access this array, but I do not
succeed in get the data as an array. I tried several things, also this:
  var prodArray = new Array(vars.get("prodArray"));

But what I get is an array with the whole comma separated content of the
original array as one string. Seems as if the array can only be stored as
string globally?

Any idea?
Thanks!
Kai

Re: Write and Read javascript arrays in BSF Processors

Posted by Kai Kaisen <ka...@googlemail.com>.
Oh yes, javadoc helped a lot here. Thank you!
Kai

On Mon, Mar 21, 2011 at 8:56 PM, sebb <se...@gmail.com> wrote:

> On 21 March 2011 18:57, Kai Kaisen <ka...@googlemail.com> wrote:
> > Hi guys,
> > I have a questions regarding javascript arrays. Can they be stored as
> > 'global variables' in jmeter?
> >
> > I have a BSF PostProcessor parsing a JSON response and storing data in an
> > javascript array:
> >  var prodArray= new Array();
> >  ...
> >  prodArray.push(prodWorkspaceName);
> >  ...
> >
> > This array gets put to jmeter variables:
> >  vars.put("prodArray", prodArray);
>
> If you have a look at the Javadoc, you will see that method takes two
> Strings.
>
> You want putObject().
>
> >
> > Now, in another BSF PreProcessor I want to access this array, but I do
> not
> > succeed in get the data as an array. I tried several things, also this:
> >  var prodArray = new Array(vars.get("prodArray"));
> >
> > But what I get is an array with the whole comma separated content of the
> > original array as one string. Seems as if the array can only be stored as
> > string globally?
> >
> > Any idea?
> > Thanks!
> > Kai
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: Write and Read javascript arrays in BSF Processors

Posted by sebb <se...@gmail.com>.
On 21 March 2011 18:57, Kai Kaisen <ka...@googlemail.com> wrote:
> Hi guys,
> I have a questions regarding javascript arrays. Can they be stored as
> 'global variables' in jmeter?
>
> I have a BSF PostProcessor parsing a JSON response and storing data in an
> javascript array:
>  var prodArray= new Array();
>  ...
>  prodArray.push(prodWorkspaceName);
>  ...
>
> This array gets put to jmeter variables:
>  vars.put("prodArray", prodArray);

If you have a look at the Javadoc, you will see that method takes two Strings.

You want putObject().

>
> Now, in another BSF PreProcessor I want to access this array, but I do not
> succeed in get the data as an array. I tried several things, also this:
>  var prodArray = new Array(vars.get("prodArray"));
>
> But what I get is an array with the whole comma separated content of the
> original array as one string. Seems as if the array can only be stored as
> string globally?
>
> Any idea?
> Thanks!
> Kai
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org