Java Code Examples for net.sf.json.JSON#toString()

The following examples show how to use net.sf.json.JSON#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpUtils.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Create Patch Request
 */
public HttpPatch createPatch(String url, JSON data) {
    HttpPatch patch = new HttpPatch(url);
    patch.setHeader("Content-Type", "application/json");

    String string = data.toString(1);
    try {
        patch.setEntity(new StringEntity(string, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    return patch;
}
 
Example 2
Source File: Feature.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static String ConvertXMLtoJSON(String xml)  {  
	XMLSerializer xmlSerializer = new XMLSerializer();  
	JSON json =null;
	  
       json = xmlSerializer.read(xml);  
	return json.toString(1);  
}
 
Example 3
Source File: Formatter.java    From DevToolBox with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static String xml2json(String xmlString) {
    XMLSerializer xmlSerializer = new XMLSerializer();
    JSON json = xmlSerializer.read(xmlString);
    return json.toString(1);
}
 
Example 4
Source File: JSONFormatter.java    From jmeter-plugins with Apache License 2.0 4 votes vote down vote up
private String formatJSON(String json) {
    JSON object = JSONSerializer.toJSON(json, config);
    return object.toString(4); // TODO: make a property to manage the indent
}