This is achieved in python, is it possible to add similar parameters in java
In the following example, interfaces are parsed into an array as expected
import json
import xmltodict
t1 = '''
<servers>
<server>
<name>host1</name>
<os>Linux</os>
<interfaces>
<interface>
<name>em0</name>
<ip_address>10.0.0.1</ip_address>
</interface>
</interfaces>
</server>
</servers>
'''
content = xmltodict.parse(t1, force_list=['servers', 'interfaces'])
data_str = json.dumps(content)
print(data_str)
output
{
"servers": [
{
"server": {
"name": "host1",
"os": "Linux",
"interfaces": [
{
"interface": {
"name": "em0",
"ip_address": "10.0.0.1"
}
}
]
}
}
]
}
is it possible to add similar parameters in java?
public JSONObject parse(String content, List<String> forceList) {
// to be
return org.json.XML.toJSONObject(content);
}
This is achieved in python, is it possible to add similar parameters in java
In the following example, interfaces are parsed into an array as expected
output
{ "servers": [ { "server": { "name": "host1", "os": "Linux", "interfaces": [ { "interface": { "name": "em0", "ip_address": "10.0.0.1" } } ] } } ] }is it possible to add similar parameters in java?