You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Asanka Perera <bj...@gmail.com> on 2019/02/15 05:41:55 UTC
Regular Expression Help
Hi All
I need some help to capture below productID and i have tried several ways
still im struggling to capture this.
Highly appreciate your support on this
Requirement:
Get the productID if isComplete is 0.
Response body :
{"ProductType":"standard","adjustedTimeLimit":"","productID":"5497365","category":"Database","dateDue":"1559793540","dateDueArray":["2019","06","05","23","59","00"],"dateExtended":0,"dateFrom":"1544245140","dateFromArray":["2018","12","07","23","59","00"],"dateTo":"1559793540","dateToArray":["2019","06","05","23","59","00"],"hasEssay":0,"hasPass":0,"isAccessible":1,"isComplete":1,"isCompleteRevoked":0,"isExempt":0,"limitStudentAccess":0,"ordinal":"1","pastDue":0,"printAllowed":"1","problemCompletedCount":6,"problemCount":6,"protectedproductID":"","showScore":"always","timeLimit":"0","title":"Load
Test product
1","viewURI":"/mycats/product?productID=5497365","workStarted":"1"},
{"ProductType":"standard","adjustedTimeLimit":"","productID":"*5497368*
","category":"Database","dateDue":"1559793540","dateDueArray":["2019","06","06","11","59","00"],"dateExtended":0,"dateFrom":"1544245140","dateFromArray":["2018","12","07","23","59","00"],"dateTo":"1559793540","dateToArray":["2019","06","05","23","59","00"],"hasEssay":0,"hasPass":0,"isAccessible":1,"
*isComplete":0,*"isCompleteRevoked":0,"isExempt":0,"limitStudentAccess":0,"ordinal":"5","pastDue":0,"printAllowed":"1","problemCompletedCount":6,"problemCount":6,"protectedproductID":"","showScore":"always","timeLimit":"0","title":"Load
Test product
6","viewURI":"/mycats/product?productID=5497368","workStarted":"1"},
{"ProductType":"standard","adjustedTimeLimit":"","productID":"5497367","category":"Database","dateDue":"1559793540","dateDueArray":["2019","08","21","23","59","00"],"dateExtended":0,"dateFrom":"1544245140","dateFromArray":["2018","12","07","23","59","00"],"dateTo":"1559793540","dateToArray":["2019","06","05","23","59","00"],"hasEssay":0,"hasPass":0,"isAccessible":1,"isComplete":1,"isCompleteRevoked":0,"isExempt":0,"limitStudentAccess":0,"ordinal":"3","pastDue":0,"printAllowed":"1","problemCompletedCount":0,"problemCount":6,"protectedproductID":"","showScore":"always","timeLimit":"0","title":"Load
Test product
4","viewURI":"/mycats/product?productID=5497367","workStarted":"1"},
Thanks
Asanka
Re: Regular Expression Help
Posted by "glinius@live.com" <gl...@live.com>.
Add JSON Extractor
<http://jmeter.apache.org/usermanual/component_reference.html#JSON_Extractor>
as a child of the request which returns the above JSON and use the following
expression:
> $..[?(@.isComplete == 0)].productID
Explanation:
1. .. - is a deep scan operator
<https://github.com/json-path/JsonPath#operators> so the expression
searches for all the *productID* attribute values
2. == is a filter operator
<https://github.com/json-path/JsonPath#filter-operators> so the expression
will return productID only when isComplete equals to 0
See JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios
<https://www.blazemeter.com/blog/advanced-usage-json-path-extractor-jmeter>
for more details on performing advanced correlation operations via JsonPath
query language
--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
Re: Regular Expression Help
Posted by Felix Schumacher <fe...@internetallee.de>.
Am 15. Februar 2019 06:41:55 MEZ schrieb Asanka Perera <bj...@gmail.com>:
>Hi All
>
>I need some help to capture below productID and i have tried several
>ways
>still im struggling to capture this.
>Highly appreciate your support on this
>
>Requirement:
>Get the productID if isComplete is 0.
The response looks like json, so you might want to have a look at the json extractor instead of writing some really complex and fragile regex.
You can use json path expressions. The post processor is documented at http://jmeter.apache.org/usermanual/component_reference.html#JSON_Extractor and has a link to examples for more json path expressions.
Regards,
Felix
>
>Response body :
>
>{"ProductType":"standard","adjustedTimeLimit":"","productID":"5497365","category":"Database","dateDue":"1559793540","dateDueArray":["2019","06","05","23","59","00"],"dateExtended":0,"dateFrom":"1544245140","dateFromArray":["2018","12","07","23","59","00"],"dateTo":"1559793540","dateToArray":["2019","06","05","23","59","00"],"hasEssay":0,"hasPass":0,"isAccessible":1,"isComplete":1,"isCompleteRevoked":0,"isExempt":0,"limitStudentAccess":0,"ordinal":"1","pastDue":0,"printAllowed":"1","problemCompletedCount":6,"problemCount":6,"protectedproductID":"","showScore":"always","timeLimit":"0","title":"Load
>Test product
>1","viewURI":"/mycats/product?productID=5497365","workStarted":"1"},
>{"ProductType":"standard","adjustedTimeLimit":"","productID":"*5497368*
>","category":"Database","dateDue":"1559793540","dateDueArray":["2019","06","06","11","59","00"],"dateExtended":0,"dateFrom":"1544245140","dateFromArray":["2018","12","07","23","59","00"],"dateTo":"1559793540","dateToArray":["2019","06","05","23","59","00"],"hasEssay":0,"hasPass":0,"isAccessible":1,"
>*isComplete":0,*"isCompleteRevoked":0,"isExempt":0,"limitStudentAccess":0,"ordinal":"5","pastDue":0,"printAllowed":"1","problemCompletedCount":6,"problemCount":6,"protectedproductID":"","showScore":"always","timeLimit":"0","title":"Load
>Test product
>6","viewURI":"/mycats/product?productID=5497368","workStarted":"1"},
>{"ProductType":"standard","adjustedTimeLimit":"","productID":"5497367","category":"Database","dateDue":"1559793540","dateDueArray":["2019","08","21","23","59","00"],"dateExtended":0,"dateFrom":"1544245140","dateFromArray":["2018","12","07","23","59","00"],"dateTo":"1559793540","dateToArray":["2019","06","05","23","59","00"],"hasEssay":0,"hasPass":0,"isAccessible":1,"isComplete":1,"isCompleteRevoked":0,"isExempt":0,"limitStudentAccess":0,"ordinal":"3","pastDue":0,"printAllowed":"1","problemCompletedCount":0,"problemCount":6,"protectedproductID":"","showScore":"always","timeLimit":"0","title":"Load
>Test product
>4","viewURI":"/mycats/product?productID=5497367","workStarted":"1"},
>
>Thanks
>Asanka
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org