Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

xml problem help

xml

  • Please log in to reply
15 replies to this topic

#13 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 27 January 2012 - 05:16 AM

What does the error say?

---------- Post added at 03:16 PM ---------- Previous post was at 02:47 PM ----------

Such thing works for me:
        XMLSerializer xmlSerializer = new XMLSerializer();
        JSON json = xmlSerializer.read("<app><user><name>Wim</name><age>21</age></user></app>");
        System.out.println(json);
Output:
{"user":{"name":"Wim","age":"21"}}
Any NoClassDefFoundError you get are "just" missing libraries.

On the site it says you need these (at least)

jakarta commons-lang 2.5
jakarta commons-beanutils 1.8.0
jakarta commons-collections 3.2.1
jakarta commons-logging 1.1.1
ezmorph 1.0.6
  • 0

#14 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 27 January 2012 - 05:22 AM

aite but, do i create instance of the json object?
I cnt seem to access the methods readFrom...
  • 0

#15 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 27 January 2012 - 05:27 AM


        XMLSerializer xmlSerializer = new XMLSerializer();

        JSON json = xmlSerializer.read("<app><user><name>Wim</name><age>21</age></user></app>");  [B] //XML String to json[/B]





        String jsonString = json.toString();

        System.out.println(jsonString);





        String write = xmlSerializer.write(json);   [B]//json String to XML[/B]

        System.out.println();

        System.out.println(write);





        JSON jsonObject = JSONObject.fromObject(jsonString);  [B]//json String to JSON object[/B]

        System.out.println(jsonObject);


  • 0

#16 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 27 January 2012 - 05:54 AM

Thank you very much, wim; I hav managed to send the xml to the server
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download