xmlToJson used to support both double and single quoted attributes. The change happened in 1.92
Added to the test xml
<minus a='complex'>
element as well
</minus>
Test with 1.91
java --class-path underscore-1.91.jar:. ToJsonTest
<mydocument has="an attribute">
<and>
<many>elements</many>
<many>more elements</many>
</and>
<plus a="complex">
element as well
</plus>
<minus a='complex'>
element as well
</minus>
</mydocument>
{
"mydocument": {
"-has": "an attribute",
"and": {
"many": [
"elements",
"more elements"
]
},
"plus": {
"-a": "complex",
"#text": "\n element as well\n "
},
"minus": {
"-a": "complex",
"#text": "\n element as well\n "
}
},
"#omit-xml-declaration": "yes"
}
Test with 1.92
java --class-path underscore-1.92.jar:. ToJsonTest
<mydocument has="an attribute">
<and>
<many>elements</many>
<many>more elements</many>
</and>
<plus a="complex">
element as well
</plus>
<minus a='complex'>
element as well
</minus>
</mydocument>
{
"mydocument": {
"-has": "an attribute",
"and": {
"many": [
"elements",
"more elements"
]
},
"plus": {
"-a": "complex",
"#text": "\n element as well\n "
},
"minus": "\n element as well\n "
},
"#omit-xml-declaration": "yes"
}
Using
public class ToJsonTest {
public static void main(String[] args) {
final String xml =
"<mydocument has=\"an attribute\">\n"
+ " <and>\n"
+ " <many>elements</many>\n"
+ " <many>more elements</many>\n"
+ " </and>\n"
+ " <plus a=\"complex\">\n"
+ " element as well\n"
+ " </plus>\n"
+ " <minus a='complex'>\n"
+ " element as well\n"
+ " </minus>\n"
+ "</mydocument>";
System.out.println(xml);
System.out.println(com.github.underscore.U.xmlToJson(xml));
}
}
xmlToJson used to support both double and single quoted attributes. The change happened in 1.92
Added to the test xml
Test with 1.91
Test with 1.92
Using