Meaningless Drivel is fun!*
The moose likes Other Open Source Projects and the fly likes JSONObject from two packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "JSONObject from two packages " Watch "JSONObject from two packages " New topic
Author

JSONObject from two packages

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

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


Save India From Corruption - Anna Hazare.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Looks like you have two JSOn libraries in your classpath. Which one were you intending to use?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Ya


I have two versions of jar files :
json-lib-2.2.2-jdk15 and json.jar

Please let me know what is standard one .
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Neither, they are two implementations of the same thing. You just need to decide which you want to use.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you .

I would like to go for json.jar.
jyothsna ananthula
Ranch Hand

Joined: Jun 02, 2011
Posts: 33
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSONObject from two packages