首页 > 解决方案 > 我有身份证清单。现在我想将它们存储在数组中以匹配 id

问题描述

Groovy Scripting中将数据存储在Array中的过程是什么

import groovy.json.JsonSlurper
def response = messageExchange.response.responseContent
def jsonsl = new JsonSlurper().parseText(response)
def count= jsonsl.photos.photo.size()

for(int i =0; i<count; i++)
{
    log.info jsonsl.photos.photo[i].id

}

标签: groovy

解决方案


如果您只想提取 ID,您应该能够:

def listOfIds = jsonl.protos.photo.id

但是如果没有一些示例 json response,很难做到 100%


推荐阅读