Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2013
    Posts
    69
    Rep Power
    0

    Default How to convert xml to json using JSONWriter?

    Hi everyone!

    I am supposed to convert XML files using JSONWriter.
    The method where i am supposed to write the conversion has this structure:
    Java Code:
    public JSONWriter wfdXmlToJson(org.w3c.dom.Document xmlDocument) {
    //TODO: 
    }
    But i don't know to use JSONWriter to do the conversion and i don't understand what the parameter inside the method refers to.
    I also have the code how a JSON is created, but I don't know where to put this slice of code :
    Java Code:
    JSONWriter jw = new JSONStringer().array();
    
    for (ModelGroupType mgt : modelGroupTypeList) {
    jw.object() 
        .key("data").value(mgt.getName())
        .key("attr").object()
        .key("identity").value(mgt.getId())
        .key("entitytype").value("MODEL_GROUP_TYPE")
        .key("class").value("model_group_type_" + mgt.getId())
    .endObject()
    }
    jw.endArray();
    
    return jw.toString();
    I don't understand what ModelGroupType refers to and what modelGroupTypelist is ...

    Anyone can help me please?
    Last edited by blertadhimitri; 11-08-2013 at 01:52 PM.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    936
    Rep Power
    2

    Default Re: How to convert xml to json using JSONWriter?


  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    936
    Rep Power
    2

    Default Re: How to convert xml to json using JSONWriter?

    And what makes you think that any forummember would know what ModelGroupType is?

  4. #4
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,894
    Rep Power
    5

    Default Re: How to convert xml to json using JSONWriter?

    Quote Originally Posted by blertadhimitri View Post
    I don't understand what ModelGroupType refers to and what modelGroupTypelist is ...
    So ask a colleague that does know it. Its code of whatever application you're building this for.

    As for not knowing this JSONWriter thing:

    JSON in Java

    Apparently the source code is the documentation. I tend to avoid frameworks and tools like that, there are plenty of far better documented JSON processors (such as Jackson or Google Gson).
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. could not convert the xml to json using java
    By cgk_js in forum Advanced Java
    Replies: 0
    Last Post: 11-30-2012, 09:31 AM
  2. convert html to json
    By nigina in forum New To Java
    Replies: 3
    Last Post: 09-22-2011, 09:38 AM
  3. Json
    By mac in forum New To Java
    Replies: 10
    Last Post: 06-08-2010, 11:15 PM
  4. JSON Lib: json-lib-1.0-jdk13.jar
    By Raghuraman K in forum Advanced Java
    Replies: 3
    Last Post: 05-13-2010, 10:00 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •