use of net.sf.json.xml.XMLSerializer in project OpenClinica by OpenClinica.
the class MetadataCollectorResource method collectODMMetadataJson.
public JSON collectODMMetadataJson(String studyOID, String formVersionOID) {
net.sf.json.xml.XMLSerializer xmlserializer = new XMLSerializer();
JSON json = xmlserializer.read(collectODMMetadataForForm(studyOID, formVersionOID));
return json;
}
use of net.sf.json.xml.XMLSerializer in project OpenClinica by OpenClinica.
the class MetadataCollectorResource method collectODMMetadataJsonString.
public String collectODMMetadataJsonString(String studyOID, String formVersionOID) {
net.sf.json.xml.XMLSerializer xmlserializer = new XMLSerializer();
JSON json = xmlserializer.read(collectODMMetadataForForm(studyOID, formVersionOID));
return json.toString(INDENT_LEVEL);
}
use of net.sf.json.xml.XMLSerializer in project tdi-studio-se by Talend.
the class ConvertJSONString method changeJsonToXml.
public static String changeJsonToXml(String jsonPath) {
Project project = ProjectManager.getInstance().getCurrentProject();
IProject fsProject = null;
try {
fsProject = ResourceUtils.getProject(project);
} catch (PersistenceException e2) {
ExceptionHandler.process(e2);
}
if (fsProject == null) {
return jsonPath;
}
String temPath = fsProject.getLocationURI().getPath() + File.separator + "temp" + File.separator + "jsonwizard" + File.separator;
try {
File file = new File(jsonPath);
String filename = file.getName().replaceAll("\\.", "_");
FileInputStream input = new FileInputStream(file);
String jsonData = IOUtils.toString(input);
XMLSerializer serializer = new XMLSerializer();
JSON json = JSONSerializer.toJSON(jsonData);
serializer.setRootName("JSONRoot");
serializer.setTypeHintsEnabled(false);
String xml = serializer.write(json);
File xmlFolder = new File(temPath);
if (!xmlFolder.exists()) {
xmlFolder.mkdirs();
}
temPath = temPath + filename + ".xml";
FileWriter writer = new FileWriter(temPath);
writer.write(xml);
writer.flush();
writer.close();
} catch (IOException e) {
ExceptionHandler.process(e);
return jsonPath;
}
return temPath;
}
Aggregations