Hello Can someone please help me extract only the value inside of square bracket. Your response is highly appreciated. Thanks and in advance.
Sample Response: var outline = {"12881":[205085,205105,205106,206407,210551,210552,210553,210554,210555,210556,210557,210558,210559,210560,210561,210562,210563,210826,210827],"12775":[205088,205089,205104,205153],"12781":[205090],"12782":[205091],"12783":[205092],"12784":[205093],"12785":[205094],"12882":[205095,208016,210678],"12883":[205096,206410],"12884":[205097,208017],"12885":[205098,208018],"12836":[205099,208324],"12886":[205100,208019,208020,208021],"12806":[205101,208330],"12807":[205102],"12810":[205103,208333],"12779":[205107],"12780":[205108,205109],"12805":[205110,208329],"12839":[205112,205113,205160,205161],"12789":[205114,205115],"12786":[205116,208201,208202,208203,208204,208205],"12816":[205127],"12788":[205128],"12811":[205129,205130,205131],"12815":[205132],"12794":[205157,208323],"12809":[205159],"12787":[206408,208206,208207,208208,208209,208210,208211],"12889":[206413,206414,206415],"12832":[206416,208189,208190,208191,208192,208193,208194,208195,208196,208197],"12833":[206417,206418,206419,206420,208198,208199,208200],"12890":[206421,206422,206423,206424,206425,206426,206427,206428],"12835":[206429,206430,206431,206432],"12834":[206433,206434,206435,206436],"12891":[206437,206438,206439,206440,206441,206442],"12887":[208058],"12888":[208059],"12965":[208183,208184,208185,208186,208187],"12933":[208188],"12812":[208212,208213],"12813":[208214,208215,208216],"12814":[208217,208218,208219],"12820":[208220,208221,208222],"12821":[208224,208225],"12819":[208226,208227],"12939":[208228,208229,208230,208231],"12940":[208232,208233],"12844":[208316,208317,208318],"12790":[208319,208325],"12791":[208320,208326],"12792":[208321,208327],"12793":[208322,208328],"12808":[208331,208332],"13058":[209018,209019,209021],"13036":[210621,210622,210623,210628],"13037":[210629],"13199":[210742,210743,210744,210745,210755,210756,210757,210758],"13038":[210828,210829,210830]};
Expected result:
205085,205105,205106,206407,210551,210552,210553,210554,210555,210556,210557,210558,210559,210560,210561,210562,210563,210826,210827
-205088,205089,205104,205153
-205091
-205092
and so on
values inside of the square bracket are dynamic. I just want to extra all values inside square bracket or "[ ]"
I think it would be easier to use JSR223 PostProcessor and JsonSlurper, the relevant code would be something like:
def json = new groovy.json.JsonSlurper().parse(prev.getResponseData())
def counter = 1
json.each { entry ->
entry.getValue().each { number ->
vars.put('value_' + counter, number as String)
counter++
}
}
Demo:
More information: