• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSONObject from two packages

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you have two JSOn libraries in your classpath. Which one were you intending to use?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neither, they are two implementations of the same thing. You just need to decide which you want to use.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you .

I would like to go for json.jar.
 
jyothsna ananthula
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic