我需要使用AFNetworking在iOS应用程序中查询Yahoo stock查询服务。 该查询返回以下结果;
YAHOO.Finance.SymbolSuggest.ssCallback({"ResultSet":{"Query":"yahoo","Result":[{"symbol":"YHOO","name":"Yahoo! Inc.","exch":"NMS","type":"S","exchDisp":"NASDAQ","typeDisp":"Equity"},{"symbol":"YHOF.EX","name":"YAHOO","exch":"EUX","type":"S","exchDisp":"EUREX Futures and Options Exchange ","typeDisp":"Equity"},{"symbol":"YOJ.BE","name":"YAHOO JAPAN","exch":"BER","type":"S","exchDisp":"Berlin","typeDisp":"Equity"},{"symbol":"YHOO.MX","name":"Yahoo! Inc.","exch":"MEX","type":"S","exchDisp":"Mexico","typeDisp":"Equity"},{"symbol":"YHO.DU","name":"YAHOO","exch":"DUS","type":"S","exchDisp":"Dusseldorf Stock Exchange ","typeDisp":"Equity"},{"symbol":"YAHOY","name":"Yahoo Japan Corporation","exch":"PNK","type":"S","exchDisp":"OTC Markets","typeDisp":"Equity"},{"symbol":"YAHOF","name":"Yahoo Japan Corporation","exch":"PNK","type":"S","exchDisp":"OTC Markets","typeDisp":"Equity"},{"symbol":"YOJ.SG","name":"YAHOO JAPAN","exch":"STU","type":"S","exchDisp":"Stuttgart","typeDisp":"Equity"},{"symbol":"YHOO.SW","name":"YAHOO","exch":"EBS","type":"S","exchDisp":"Swiss","typeDisp":"Equity"},{"symbol":"YHO.HM","name":"YAHOO","exch":"HAM","type":"S","exchDisp":"Hamburg","typeDisp":"Equity"}]}})
如您所见,JSON格式不正确。具体来说,不需要YAHOO.Finance.SymbolSuggest.ssCallback()并导致JSON格式化程序崩溃。
有没有办法告诉AFNetworking跳过不属于实际JSON的文本?
编辑: 根据@rckoenes的要求;这就是webservice的使用方式; http://www.jarloo.com/yahoo-stock-symbol-lookup/
答案 0 :(得分:0)
看起来这不是公共API,因此您可能无法使用它。当然你还可以。只需创建自己的响应序列化程序结束,然后解码JSON删除第一部分,看起来简单的字符串替换并删除最后一个章程。这应该返回有效的JSON。