Groovy web console

subscribe to the feed Subscribe
to this
site

jfrog json parsing

Published 3 months ago by daggett with tags json jfrog
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def jsonOutput = new groovy.json.JsonSlurper().parseText(''' { "results" : [ {   "repo" : "libs-snapshot-local",   "path" : "simple-integration/2.5.150",   "name" : "simple-integration-2.5.150.jar",   "type" : "file",   "size" : 1175,   "created" : "2019-06-23T19:51:30.367+05:30",   "created_by" : "admin",   "modified" : "2019-06-23T19:51:30.364+05:30",   "modified_by" : "admin",   "updated" : "2019-06-23T19:51:30.368+05:30" },{   "repo" : "libs-snapshot-local",   "path" : "simple-integration/2.5.140",   "name" : "simple-integration-2.5.140.jar",   "type" : "file",   "size" : 1175,   "created" : "2019-06-21T19:52:40.670+05:30",   "created_by" : "admin",   "modified" : "2019-06-21T19:52:40.659+05:30",   "modified_by" : "admin",   "updated" : "2019-06-21T19:52:40.671+05:30" },{   "repo" : "libs-snapshot-local",   "path" : "simple-integration/2.5.150",   "name" : "simple-integration-2.5.160.jar",   "type" : "file",   "size" : 1175,   "created" : "2019-06-28T19:58:04.973+05:30",   "created_by" : "admin",   "modified" : "2019-06-28T19:58:04.970+05:30",   "modified_by" : "admin",   "updated" : "2019-06-28T19:58:04.973+05:30" } ], "range" : {   "start_pos" : 0,   "end_pos" : 3,   "total" : 3 } } ''')

def last = jsonOutput.results.sort{a, b -> b.created <=> a.created }[0] 
println last.created 
println last.name