【发布时间】:2011-03-21 10:04:43
【问题描述】:
我正在使用此查询通过 JSON 解析从网络服务器获取数据到我的 iPhone 应用程序。
SELECT a.FundID, a.FundName, a.Strike, a.LongShort, a.Current, a.Points, a.OpenClose
FROM tbl_Positions a, tbl_FundStatic b
WHERE b.FundID = a.FundID
AND b.UserID = '14'
AND a.OpenClose != 'Close'
UNION
SELECT c.FundID, c.FundName, '0' AS Strike, "-" AS LongShort, b.LastTradePrice, '0' AS Points, "-" AS OpenClose
FROM tbl_FundStatic c, tbl_MarketData b
WHERE c.UserID = '14'
AND b.IndexCode = c.`Index`
AND c.FundID NOT
IN (
SELECT DISTINCT (FundID)
FROM tbl_Positions
)
理想情况下它应该返回像
这样的数据但它显示 Points 和 Strike 列的垃圾值(如“MA==”等)。
可能出了什么问题?
编辑:
我正在使用 SBJSON 解析器。
我正在使用以下代码在服务器端将数据解析为 JSON 字符串:
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(dt);
objMyCon.Close();
String jsonString = JsonConvert.SerializeObject(dt);
String finalString = "{\"ExecuteTrade\":";
finalString += jsonString;
finalString += "}";
return finalString;
finalString 值
{"ExecuteTrade":[{"FundID":28,"FundName":"Sam Fund 2","Strike":"MTIxMzA=","LongShort":"Long","Current":11985.00,"Points":"LTE0NQ==","OpenClose":"Open"},
{"FundID":27,"FundName":"Sam Fund 1","Strike":"MTE5ODU=","LongShort":"Long","Current":11985.00,"Points":"NTAwMDA=","OpenClose":"Open"},
{"FundID":32,"FundName":"Sam Fund 3","Strike":"MjIwMDA=","LongShort":"Long","Current":14000.00,"Points":"NjAwMA==","OpenClose":"Open"},
{"FundID":45,"FundName":"Rob Fund test","Strike":"OTk5OQ==","LongShort":"NULL","Current":11984.61,"Points":"OTk5OQ==","OpenClose":"NULL"},
{"FundID":46,"FundName":"newtestfund5th","Strike":"OTk5OQ==","LongShort":"NULL","Current":11984.61,"Points":"OTk5OQ==","OpenClose":"NULL"}]}
这是数据表:
在应用端我正在使用
NSDictionary *diction = [responseString JSONValue];
注意:查询在服务器上执行时工作正常。
【问题讨论】: