SaHiN 14 Posted July 30, 2015 Report Share Posted July 30, 2015 Hi, my json code: { "status": "ok", "items": [{ "subtitle": "Ankara", "location": { "external_source": "demo", "city": "turkey", "code": 88589, }, "media_bundles": [] }, { "subtitle": "Ankara", "location": { "external_source": "demo", "city": "usa", "code": 5252525, }, "media_bundles": [] } } city-code turkey-88589usa-5252525 how can ı do upper format? (aymen jsonPath parser or enother plugin ?) Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted August 1, 2015 Report Share Posted August 1, 2015 I'd roll this way SaHin, set(#json code,"\{ \"status\": \"ok\", \"items\": [\{ \"subtitle\": \"Ankara\", \"location\": \{ \"external_source\": \"demo\", \"city\": \"turkey\", \"code\": 88589, \}, \"media_bundles\": [] \}, \{ \"subtitle\": \"Ankara\", \"location\": \{ \"external_source\": \"demo\", \"city\": \"usa\", \"code\": 5252525, \}, \"media_bundles\": [] \}\}","Global")clear list(%zipped)clear list(%cities)clear list(%codes)add list to list(%cities,$list from text($find regular expression(#json code,"(?<=\"city\":\\s\").*?(?=\")"),$new line),"Don\'t Delete","Global")add list to list(%codes,$list from text($find regular expression(#json code,"(?<=\"code\":\\s).*?(?=,)"),$new line),"Don\'t Delete","Global")loop($list total(%cities)) { add item to list(%zipped,"{$next list item(%cities)} -- {$next list item(%codes)}","Don\'t Delete","Global")} usin the plugin tho should lool like$..code but not working in U5regex is more reliable in this case.CD 1 Quote Link to post Share on other sites
mithcd 4 Posted August 1, 2015 Report Share Posted August 1, 2015 (edited) Hi Sahin, did the code work for you? Edited August 1, 2015 by mithcd Quote Link to post Share on other sites
deliter 203 Posted August 6, 2015 Report Share Posted August 6, 2015 the JSON their is incorrect,it should be var findTown ={ "status": "ok", "items": [{ "subtitle": "Ankara", "location": { "external_source": "demo", "city": "turkey", "code": 88589, }, "media_bundles": [] }, { "subtitle": "Ankara", "location": { "external_source": "demo", "city": "usa", "code": 5252525, }, "media_bundles": [] }]} that is probably why the plugin wasn't working clear list(%towns)run javascript("var findTown =\{ \"status\": \"ok\", \"items\": [\{ \"subtitle\": \"Ankara\", \"location\": \{ \"external_source\": \"demo\", \"city\": \"turkey\", \"code\": 88589, \}, \"media_bundles\": [] \}, \{ \"subtitle\": \"Ankara\", \"location\": \{ \"external_source\": \"demo\", \"city\": \"usa\", \"code\": 5252525, \}, \"media_bundles\": [] \}]\}")set(#position,0,"Global")set(#listCount,$eval("findTown.items.length"),"Global")loop(#listCount) { set(#town,$eval("findTown.items[{#position}].location.city"),"Global") set(#code,$eval("findTown.items[{#position}].location.code"),"Global") add item to list(%towns,"{#town}-{#code}","Delete","Global") increment(#position)} 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.