### Question:
JsonUtils { public static String toJson(Object obj) { return toJson(obj, false); }  static String toJson(Object obj); static String toJson(Object obj, boolean prettyPrinter); static String toJson(String str); static T fromJson(Class<T> clazz, String json); static T fromJson(final TypeReference<T> type, final String json);  }### Answer:
@Test void toJsonTest() { TemplateDefinition t1 = new TemplateDefinition(); t1.setId("Test template").setDescription("This is a test.").setFilenamePattern("Contract"); assertEquals("{\"refId\":1,\"variableDefinitions\":[],\"dependentVariableDefinitions\":[],\"id\":\"Test template\",\"description\":\"This is a test.\",\"filenamePattern\":\"Contract\",\"stronglyRestrictedFilenames\":true,\"autoGenerated\":false}", JsonUtils.toJson(t1)); t1.add(createVar("Name", true, true)); t1.add(createVar("Gender", true, false)); String json = JsonUtils.toJson(t1); TemplateDefinition t2 = JsonUtils.fromJson(TemplateDefinition.class, json); assertTemp(t1, t2); }
@Test void fileDescriptorTest() { FileDescriptor fileDescriptor = new FileDescriptor(); Path path = Paths.get("/Users/kai/Documents"); fileDescriptor.setDirectory(path); path = Paths.get("/Users/kai/Documents/templates/test.xlsx"); fileDescriptor.setRelativePath(path); String json = JsonUtils.toJson(fileDescriptor, true); log.info(json); assertEquals("/Users/kai/Documents/templates/test.xlsx", normalize(PersistencyRegistry.getDefault().getCanonicalPathString(path))); }