Ravi Kiran Va wrote:Hi ,
I am trying to use JSON in my project i am seeing that JSONObject can be from two packages .
Please tell me what is the difference between them
hi i want to know how to convert xml file to json object
please see the following code
import net.sf.json.JSON;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.io.IOUtils;
import java.io.*;
import org.json.XML;
import org.apache.commons.io.IOUtils;
import java.io.*;
import org.json.XML;
class ConvertJson {
public static void main(
String[] args) throws Exception {
InputStream is = new FileInputStream(new File("C:\\Documents and Settings\\JA0084604\\Desktop\\NMS\\XO-OpenNMS\\build.xml"));
String xml = IOUtils.toString(is);
// XMLSerializer xmlSerializer = new XMLSerializer();
JsonObject jsonObject=new JsonObject();
jsonObject = XML.toJSONObject( xml );
System.out.println( json.toString(2) );
}
}
for this actually i don't have jars org.json.xml.
please let me these code is enough to get json object.
and in program how to find out there is specific jars are needed.
because i am getting error only can't find symbol with following classname.