第一种:
import com.google.gson.*; def pretty = new GsonBuilder().setPrettyPrinting().create().toJson(new JsonParser().parse("$Parameters")) log.info "\n 查询H5短链接列表结果是: \n $pretty"
第二种:
需要导入json-io-4.12.0.jar 包
下载地址:https://jar-download.com/artifacts/com.cedarsoftware/json-io/4.13.0/source-code
import com.cedarsoftware.util.io.JsonWriter def pretty = JsonWriter.formatJson("$Parameters") log.info "\n 查询H5短链接列表结果是: \n $pretty"
第三种:
需要导入json-20210307.jar 包
下载地址:https://jar-download.com/maven-repository-class-search.php?search_box=org.json.JSONWriter
import org.json.*; JSONObject jsonObject = new JSONObject("$Parameters"); def pretty = jsonObject.toString(4); log.info "\n 查询H5短链接列表结果是: \n $pretty"