返回 AFNetworking 无效 JSON 格式

AFNetworking invalid JSON format returned

我需要使用 AFNetworking 在 iOS 应用程序中查询 Yahoo 股票查询服务。 查询returns如下结果;

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 的要求;这就是 web 服务的使用方式; http://www.jarloo.com/yahoo-stock-symbol-lookup/

看起来这不是 public API,因此您可能无法使用它。当然你仍然可以。在解码 JSON 删除第一部分之前,只需创建您自己的响应序列化程序端,使用看似简单的字符串替换并删除最后一个章程。这应该 return 有效 JSON。