第一種:
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"