json - Process a list of map to get a value of a key in the map -


i have list of map (parsed json output of rest request) like

[[mobile:9876543210, name:abcd], [mobile:8765432109, name:efgh], [mobile:7654321098, name:ijkl], [mobile:6543210987, name:mnop]]  

original json like

{     "data": [{             "name": "abcd",             "mobile": "9876543210"         },         {             "name": "efgh",             "mobile": "8765432109"         },         {             "name": "ijkl",             "mobile": "7654321098"         },         {             "name": "mnop",             "mobile": "6543210987"         }     ] } 

i want mobile value name

tried things not working out.

trying in jmeter jsr223 post processor using groovy.

you should able mobile based on name.

below code fetches mobile 8765432109 when name efgh op's data. can change value of name right mibile.

//pass jsonstring value below parsetext method def json = new groovy.json.jsonslurper().parsetext(jsonstring) def result = json.data.find { it.name == 'efgh' }.mobile println result 

you can try online demo


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -