How to correlate with dynamic variable length Left & Right boundary

651 views
Skip to first unread message

sathish Ram

unread,
Jun 26, 2015, 9:48:51 AM6/26/15
to LR-Loa...@googlegroups.com

Hi Everyone,

Please let me know how to correlate the SKU values here

{"id":"6657003908","catalogId":"30000","categoryId":"406","productId":"864","skuId":"32013","quantity":"1","classType":"subSkuCommerceItem"},

{"id":"6657003909","catalogId":"30000","categoryId":"406","productId":"6254","skuId":"32113","quantity":"1","classType":"subSkuCommerceItem"},

{"id":"6657003903","catalogId":"30000","categoryId":"406","productId":"3162","skuId":"32039","quantity":"1","classType":"subSkuCommerceItem"},

{"id":"6657003926","catalogId":"30000","categoryId":"406","productId":"6251","skuId":"73102","quantity":"1","classType":"subSkuCommerceItem"},

{"id":"6657003884","catalogId":"30000","categoryId":"409","productId":"3969","skuId":"44100","quantity":"1","classType":"subSkuCommerceItem"},

{"id":"6657003885","catalogId":"30000","categoryId":"409","productId":"3968","skuId":"44101","quantity":"1","classType":"subSkuCommerceItem"},

We are getting the above server response

When I use below correlation

web_reg_save_param("brkprd_array","LB=categoryId\":\"406\",\"productId\":\"","RB=\",\"skuId\":\"","ORD=All","NotFound=Warning",LAST);

Answer: It list out all the product ids

    Now I want to capture the sku id’s whose category id is 406

I used below

web_reg_save_param ("brksk_array","LB=\"skuId\":\"3","RB=\",\"quantity","ORD=ALL","NotFound=Warning",LAST);

its failing in some cases SKU ids starting with 3 and some cases starts with 7

Description: In some cases sku id for category 406 is coming as 3 and some other times as 7 so I am not ble to capture the complete set

Thought of using the /DIG or savelen but product id is not of same length some times its 4 digit and some times its of 3 digit(product id).

Please help me in resolving it

James Pulley

unread,
Jun 26, 2015, 10:35:23 AM6/26/15
to LR-Loa...@googlegroups.com, sathis...@gmail.com
Alter your original to the following (changes bolded and in blue)

web_reg_save_param("brkprd_array","LB=categoryId\":\"406\",\"productId\":\"","RB= \",\"quantity\"","ORD=All","NotFound=Warning",LAST);

this will leave you with strings such as 

brkprd_array_1 = 864","skuId":"32013
brkprd_array_2 = 6254","skuId":"32113
brkprd_array_3 = 3162","skuId":"32039
brkprd_array_4 = 6251","skuId":"73102
brkprd_array_count = 4


You have a defined record structure here and a distinct separator, the string construct, " \",\"skuId\":\" ".    Use this defined structure along with an algorithm of your own construction to pull out the data that you need.   Here is a fragment you may find interesting as you put your own code together

lr_message( 
     " Look, an SKU id of %s", 
     lr_eval_string("{brkprd_array_1}")[  strlen( lr_eval_string("{brkprd_array_1}") - 5]  )
    );


James Pulley
NewCOE, LiteSquare, LoadRunnerByTheHour, TheScriptFarm, Cloud-Architect, PerfBytes
...

André Luyer

unread,
Jun 29, 2015, 8:15:15 AM6/29/15
to LR-Loa...@googlegroups.com
Variable length boundaries? Use regex!

This matches all 4 in the example:
web_reg_save_param_regexp(
"ParamName=brksk_array",
"RegExp=\"categoryId\":\"406\",\"productId\":\"\\d*\",\"skuId\":\"(\\d+)",
"Ordinal=All",
LAST);

Or a bit more risky regex:
"RegExp=\"categoryId\":\"406\",.*?\"skuId\":\"(\\d+)",

In post processing lr_save_param_regexp may also be useful.

André
...
Reply all
Reply to author
Forward
0 new messages