class JsonUtils {

    public static String xml2json(String xml, Boolean pretty) {
        try {
            // name spaces cause problems, so just remove them
            JSONObject jsonObj = XML.toJSONObject(XmlTool.removeNamespaces(xml));
            if (!pretty) {
                return jsonObj.toString();
            } else {
                // add an indent to make it 'pretty'
                return jsonObj.toString(MSOJsonIndentFactor);
            }
        } catch (Exception e) {
            logger.debug("xml2json(): unable to parse xml and convert to json. Exception was: {}", e.toString(), e);
            return null;
        }
    }

}