簡體   English   中英

將 XML 轉換為 Json 期間布爾值的問題

[英]Issue with boolean during conversion Xml to Json

我使用此代碼( 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”轉換為布爾值。 我需要將所有字段都轉換為字符串。

使用keepStrings=false參數。 這里

keepStrings If true, then values will
not be coerced into boolean or numeric values and will instead be left as strings

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM