Search in sources :

Example 6 with XMLSerializer

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;
}
Also used : XMLSerializer(net.sf.json.xml.XMLSerializer) XMLSerializer(net.sf.json.xml.XMLSerializer) JSON(net.sf.json.JSON)

Example 7 with XMLSerializer

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);
}
Also used : XMLSerializer(net.sf.json.xml.XMLSerializer) XMLSerializer(net.sf.json.xml.XMLSerializer) JSON(net.sf.json.JSON)

Example 8 with XMLSerializer

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;
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) XMLSerializer(net.sf.json.xml.XMLSerializer) FileWriter(java.io.FileWriter) PersistenceException(org.talend.commons.exception.PersistenceException) JSON(net.sf.json.JSON) IOException(java.io.IOException) File(java.io.File) IProject(org.eclipse.core.resources.IProject) FileInputStream(java.io.FileInputStream)

Aggregations

XMLSerializer (net.sf.json.xml.XMLSerializer)8 JSON (net.sf.json.JSON)6 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 JSONArray (net.sf.json.JSONArray)1 JSONObject (net.sf.json.JSONObject)1 FullReportBean (org.akaza.openclinica.bean.extract.odm.FullReportBean)1 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)1 IProject (org.eclipse.core.resources.IProject)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Project (org.talend.core.model.general.Project)1