我有此JSON例如:XSTREAM JSON - 如何處理空值
{
"rows": [
{
"anaid": "1",
"anaint": "123",
"anastring": "-"
},
{
"anaid": "2",
"anaint": "-",
"anastring": "Hello World"
},
{
"anaid": "3",
"anaint": "-",
"anastring": "-"
}
]
}
凡在我的課測試是:
- INT阿奈德
- INT anaint
- 字符串anastring
我的java代碼:
XStream xstream = new XStream(new JettisonMappedXmlDriver());
xstream.alias("rows", Test.class);
ArrayList<Test> product = (ArrayList<Test>) xstream.fromXML(json);
所以字符「 - 」是我的json的空值。我無法更改代碼來創建json,但我會處理「 - 」null值以正確使用我的xStream解析器。
我已閱讀,但我不明白我該怎麼辦... – CeccoCQ