我使用此代码(org.json
)将XML转换为JSON:
String xml = "...<field>TRUE</field>...";
JSONObject response = XML.toJSONObject(xml);
response.toString(); // "field": true
// but I need "field": TRUE as in xml
问题是我不想在布尔值中转换“TRUE”。我需要将所有字段转换为String。
答案 0 :(得分:0)
使用keepStrings=false
参数。请参阅here。
keepStrings If true, then values will
not be coerced into boolean or numeric values and will instead be left as strings