You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by zinedine <as...@avaya.com> on 2011/06/08 15:58:54 UTC
regex to mach a json
Hello,
I need to make a test that needs to get a JSON and then send it in a put
request.
I need to use the regex extractor to get the entire JSON, but I don't know
what regular expresion to use, because I need to extract only the response
inside the [] brackets.
example:
retrieved JSON : [{"name":"customer", "id":3, "phone":"555"}]
what I have to send is only {"name":"customer", "id":3, "phone":"555"}.
What regular expresion should I use?
--
View this message in context: http://jmeter.512774.n5.nabble.com/regex-to-mach-a-json-tp4469591p4469591.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
RE: regex to mach a json
Posted by Thom Hehl <Th...@pointsix.com>.
All I know is to match Shakespeare you'd use:
/(bb|[^b]{2})/
:D
-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com]
Sent: Wednesday, June 08, 2011 11:46 AM
To: JMeter Users List
Subject: Re: regex to mach a json
On 8 June 2011 16:33, zinedine <as...@avaya.com> wrote:
> It doesn't work as you said, and what I have is a variable JSON, that
is why
> I need to get it before put it in another request.
> I just need a regular expresion that helps me get rid of the [ ]
brackets at
> the beggining and at the end of the expression...but I don't know how
to
> make it..
Oops, my second example should have been:
\[([^]]+)\]
Try
http://jakarta.apache.org/oro/demo.html
Also see:
http://jakarta.apache.org/jmeter/usermanual/regular_expressions.html
> --
> View this message in context:
http://jmeter.512774.n5.nabble.com/regex-to-mach-a-json-tp4469591p446989
6.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: regex to mach a json
Posted by sebb <se...@gmail.com>.
On 8 June 2011 16:33, zinedine <as...@avaya.com> wrote:
> It doesn't work as you said, and what I have is a variable JSON, that is why
> I need to get it before put it in another request.
> I just need a regular expresion that helps me get rid of the [ ] brackets at
> the beggining and at the end of the expression...but I don't know how to
> make it..
Oops, my second example should have been:
\[([^]]+)\]
Try
http://jakarta.apache.org/oro/demo.html
Also see:
http://jakarta.apache.org/jmeter/usermanual/regular_expressions.html
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/regex-to-mach-a-json-tp4469591p4469896.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: regex to mach a json
Posted by Deepak Shetty <sh...@gmail.com>.
or
variable name = whateveryouwanttouse
Regex = ({[^}]*}) =>
Capture(represent by '(' )
the character '{'
followed by any character(the [] not to be confused with the Json
[])
which is not(the ^) a '}' ,
any amount of times (the *) followed by a '}' ,
end capturing
Template = $1$
Match no = 1
Default = NOT FOUND
(Regex does not deal with if your values in the JSON themselves have } or if
the JSON has newline characters)
Then ensure that you have the regex post processor as a *child* of the
sampler that returns the JSON string. If it still doesnt work , add a debug
sampler after the sampler returning the JSON and add a view results tree
listener and check the Response you are getting for the sampler which is
returning the JSON. Post the exact response here. Also check the response of
the Debug Sampler and see the value for the variable name you specified in
the regex, if it is correct here, then you are making a mistake when you are
using the variable
regards
deepak
On Wed, Jun 8, 2011 at 8:33 AM, zinedine <as...@avaya.com> wrote:
> It doesn't work as you said, and what I have is a variable JSON, that is
> why
> I need to get it before put it in another request.
> I just need a regular expresion that helps me get rid of the [ ] brackets
> at
> the beggining and at the end of the expression...but I don't know how to
> make it..
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/regex-to-mach-a-json-tp4469591p4469896.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
Re: regex to mach a json
Posted by zillakilla <zi...@sogetthis.com>.
\[(.*)\]
zK
--
View this message in context: http://jmeter.512774.n5.nabble.com/regex-to-mach-a-json-tp4469591p4469959.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: regex to mach a json
Posted by zinedine <as...@avaya.com>.
It doesn't work as you said, and what I have is a variable JSON, that is why
I need to get it before put it in another request.
I just need a regular expresion that helps me get rid of the [ ] brackets at
the beggining and at the end of the expression...but I don't know how to
make it..
--
View this message in context: http://jmeter.512774.n5.nabble.com/regex-to-mach-a-json-tp4469591p4469896.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: regex to mach a json
Posted by sebb <se...@gmail.com>.
On 8 June 2011 14:58, zinedine <as...@avaya.com> wrote:
> Hello,
> I need to make a test that needs to get a JSON and then send it in a put
> request.
> I need to use the regex extractor to get the entire JSON, but I don't know
> what regular expresion to use, because I need to extract only the response
> inside the [] brackets.
> example:
> retrieved JSON : [{"name":"customer", "id":3, "phone":"555"}]
> what I have to send is only {"name":"customer", "id":3, "phone":"555"}.
> What regular expresion should I use?
For the example quoted, the following would work:
({"name":"customer", "id":3, "phone":"555"})
or
\[(^])+\]
It really depends on what varies and what the context is.
Use the Tree View Listener Regex tab to experiment on an actual response.
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/regex-to-mach-a-json-tp4469591p4469591.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org