如何在Android中处理JSON响应?

时间:2015-11-09 18:36:26

标签: android json

我是Android的新手,我正在尝试处理有关请求的JSON响应,例如:

https://s.yimg.com/aq/autoc?query=YH&region=US&lang=en-US&callback=whatever

给出响应(看起来像一个函数调用):

whatever({"ResultSet":{"Query":"YH","Result":[{"symbol":"YHOO","name":"Yahoo! Inc.","exch":"NAS","type":"S","exchDisp":"NASDAQ","typeDisp":"Equity"},{"symbol":"YHO.DE","name":"Yahoo! Inc.","exch":"GER","type":"S","exchDisp":"XETRA","typeDisp":"Equity"},{"symbol":"YHO.HM","name":"YAHOO","exch":"HAM","type":"S","exchDisp":"Hamburg","typeDisp":"Equity"},{"symbol":"002304.SZ","name":"YHGF","exch":"SHZ","type":"S","exchDisp":"Shenzhen","typeDisp":"Equity"},{"symbol":"Y08.SI","name":"YHI International Limited","exch":"SES","type":"S","exchDisp":"Singapore","typeDisp":"Equity"},{"symbol":"YHOO151120C00035000","name":"YHOO Nov 2015 call 35.000","exch":"OPR","type":"O","exchDisp":"OPR","typeDisp":"Option"},{"symbol":"YHOO151218C00035000","name":"YHOO Dec 2015 call 35.000","exch":"OPR","type":"O","exchDisp":"OPR","typeDisp":"Option"},{"symbol":"YHOO.MX","name":"Yahoo! Inc.","exch":"MEX","type":"S","exchDisp":"Mexico","typeDisp":"Equity"},{"symbol":"YHOO151218C00040000","name":"YHOO Dec 2015 call 40.000","exch":"OPR","type":"O","exchDisp":"OPR","typeDisp":"Option"},{"symbol":"YHO.DU","name":"YAHOO","exch":"DUS","type":"S","exchDisp":"Dusseldorf Stock Exchange","typeDisp":"Equity"}]}});

为了处理这个响应,我只是在最后删除字符whatever(和括号),或者我可以以更复杂的方式使用这种字符串。我找到了一些信息https://briancaos.wordpress.com/2015/04/27/sitecore-8-exm-get-the-email-recipient-from-a-sublayout/here,但我甚至不确定那些与我的问题有关。

我可以以更复杂的方式使用我的响应,还是应该从该函数中删除参数?

0 个答案:

没有答案