I am trying to convert this XML file/ or any XML file to JSON object.
<classes>
<class>
<name>MORN CS</name>
<subjects>
<subject>
<title>COM101</title>
<lessons>
<lesson>
<header>Basic</header>
<desc>Insert description here</desc>
</lesson>
<lesson>
<header>Intros</header>
<desc>lorem ipsum </desc>
</lesson>
</lessons>
</subject>
</subjects>
</class>
</classes>
I have tried the code in this link but i have no idea to implement it using JDOM and its result is not the same on the xml file. Convert xml file to json object using dom parser in java This is the result
{
"classes": [
{
"class": [
{
"subjects": [
{
"subject": [
{
"title": "COM101",
"lessons": [
{
"lesson": [
{
"header": "Intros",
"desc": "lorem ipsum "
}
]
}
]
}
]
}
],
"name": "MORN CS"
}
]
}
]}
Well my question is how could I convert my xml file to an JSONObject in Java?? Could someone give me idea or any help is much appreciated.