如何将以下值转换为 json(字符串到 JSON 数组)

How to convert following values to json(String to JSON Array)

我有以下字符串形式的数据,我希望它们是 json。

data= [[[name: abc, age: 20], [name:xyz, age 25]], [[count: 2]]]

我尝试了 Json.parse() 和 new JsonArray() 但它抛出了一个异常 "expection a ',' or ']'"。 谁能帮我把它转换成 JSON?

你需要

def json = JsonOutput.toJson(data)