com.kazurayam.ks.globalvariable.JsonUtil.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ExecutionProfilesLoader Show documentation
Show all versions of ExecutionProfilesLoader Show documentation
A Katalon Studio plugin that enables loading Execution Profiles in test scripts
package com.kazurayam.ks.globalvariable
import com.google.gson.Gson
import com.google.gson.GsonBuilder
public class JsonUtil {
public static String prettyPrint(String sourceJson) {
return prettyPrint(sourceJson, Map.class);
}
public static String prettyPrint(String sourceJson, Class clazz) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
// parse JSON text to a Map
Object obj = gson.fromJson(sourceJson, clazz);
// serialize the object back to a JSON text in pretty-print format
return gson.toJson(obj);
}
}