• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JSON to XML Conversion

 
Ranch Hand
Posts: 157
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have one JSON file and task is to convert into XML. Attached is my java file through, Getting an error at line 30 Exception in thread "main" java.lang.NoSuchMethodError: nu.xom.Serializer.getEncoding()Ljava/lang/String;. Please check.



Thanks
 
Ranch Hand
Posts: 733
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have one JSON file and task is to convert into XML. Attached is my java file through, Getting an error at line 30 Exception in thread "main" java.lang.NoSuchMethodError: nu.xom.Serializer.getEncoding()Ljava/lang/String;


Make sure you have xom.jar in your classpath?
 
vivek dhiman
Ranch Hand
Posts: 157
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.

I got to know that I had the xom.jar file. & had the Serializer class in that, which doesn't have getEncoding() method. Thats the reason i am getting such error. These libraries provided by client so not able to alter . Trying to find out another solution.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vivek,

Please try the below code snippet.

JSONObject o = new JSONObject("{'glossary': {'title': 'example glossary','GlossDiv': {'title': 'S','GlossList': {'GlossEntry': {'ID': 'SGML','SortAs': 'SGML','GlossTerm': 'Standard Generalized Markup Language','Acronym': 'SGML','Abbrev': 'ISO 8879:1986','GlossDef': {'para': 'A meta-markup language, used to create markup languages such as DocBook.', 'GlossSeeAlso': ['GML', 'XML']},'GlossSee': 'markup'}} } } }");

String xml = org.json.XML.toString(o);

System.out.println(xml);

Above stuff should work with out adding any new jars. Try and let me know with the output.
reply
    Bookmark Topic Watch Topic
  • New Topic