package app
import java.io.ByteArrayInputStream;
import org.json.JSONObject;
import org.json.XML;
public class ConvertXMLtoJSONOSB {
public static String getConvertXMLtoJSON(String one) throws Exception
{
ByteArrayInputStream stream = new ByteArrayInputStream(one.getBytes());
StringBuilder builder = new StringBuilder();
int ptr = 0;
while ((ptr = stream.read()) != -1 )
{
builder.append((char) ptr);
}
String xml = builder.toString();
JSONObject jsonObj = XML.toJSONObject(xml);
String result = jsonObj.toString();
System.out.println(result);
return result;
}
import java.io.ByteArrayInputStream;
import org.json.JSONObject;
import org.json.XML;
public class ConvertXMLtoJSONOSB {
public static String getConvertXMLtoJSON(String one) throws Exception
{
ByteArrayInputStream stream = new ByteArrayInputStream(one.getBytes());
StringBuilder builder = new StringBuilder();
int ptr = 0;
while ((ptr = stream.read()) != -1 )
{
builder.append((char) ptr);
}
String xml = builder.toString();
JSONObject jsonObj = XML.toJSONObject(xml);
String result = jsonObj.toString();
System.out.println(result);
return result;
}
No comments:
Post a Comment