我正在使用此查询从Web服务器将数据提取到我的iPhone应用程序使用JSON解析。从Web服务器提取数据到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];
注:当服务器上执行查询工作正常。
不错的工作!自己找到答案总是更令人满意。 – 2011-03-21 21:24:55
是的非常真实!谢谢 :) – 2011-03-22 04:42:45