我在某些节点中有包含一些 html 内容的 xml,例如
<detail>
<P>Students should avoid purchasing their textbooks at the first store that they browse. Instead, they should investigate the alternatives offered by other online booksellers. Price isn't the only factor to consider when making an online purchase. Students should also factor in shipping costs and delivery time when making their buying decision.</P>
</detail>
而通过 json 或 json-lib 从 xml 转换为 Json,通过
import net.sf.json.JSON;
import net.sf.json.xml.XMLSerializer;
.....
JSONObject jsonObject = XML.toJSONObject(xml.toString());
......
xml 是包含 xml 内容的字符串
我应该得到 json 字符串
{"detail":"<P>Students should avoid purchasing their textbooks at the first store that they browse. Instead, they should investigate the alternatives offered by other online booksellers. Price isn't the only factor to consider when making an online purchase. Students should also factor in shipping costs and delivery time when making their buying decision.</P>"}
但输出类似于
{"detail":{"P":"Students should avoid purchasing their textbooks at the first store that they browse. Instead, they should investigate the alternatives offered by other online booksellers. Price isn't the only factor to consider when making an online purchase. Students should also factor in shipping costs and delivery time when making their buying decision."}}
这是不合适的。
谁能告诉我如何解决这个问题?