jQuery读取并输出JSON数据
我有来自雅虎(YQL)的提要,需要将一些信息输出到网页。有人可以帮忙吗?谢谢!!这让我非常头痛。哈哈
cbfunc({
"query": {
"count": "1",
"created": "2010-12-07T10:38:18Z",
"lang": "en-US",
"results": {
"quote": {
"symbol": "^FTSE",
"Ask": null,
"AverageDailyVolume": "0",
"Bid": null,
"AskRealtime": null,
"BidRealtime": null,
"BookValue": null,
"Change_PercentChange": "+67.33 - +1.17%",
"Change": "+67.33",
"Commission": null,
"ChangeRealtime": "+67.33",
"AfterHoursChangeRealtime": "N/A - N/A",
"DividendShare": null,
"LastTradeDate": "12/7/2010",
"TradeDate": null,
"EarningsShare": null,
"ErrorIndicationreturnedforsymbolchangedinvalid": "N/A",
"EPSEstimateCurrentYear": null,
"EPSEstimateNextYear": null,
"EPSEstimateNextQuarter": null,
"DaysLow": "5769.67",
"DaysHigh": "5838.52",
"YearLow": "4790.04",
"YearHigh": "5902.11",
"HoldingsGainPercent": "- - -",
"AnnualizedGain": "-",
"HoldingsGain": null,
"HoldingsGainPercentRealtime": "- - -",
"HoldingsGainRealtime": null,
"MoreInfo": "cnv",
"OrderBookRealtime": "N/A",
"MarketCapitalization": null,
"MarketCapRealtime": null,
"EBITDA": null,
"ChangeFromYearLow": null,
"PercentChangeFromYearLow": null,
"LastTradeRealtimeWithTime": "5:20am - <b>5837.61</b>",
"ChangePercentRealtime": "+67.33 - +1.17%",
"ChangeFromYearHigh": null,
"PercebtChangeFromYearHigh": null,
"LastTradeWithTime": "5:20am - <b>5837.61</b>",
"LastTradePriceOnly": "5837.61",
"HighLimit": null,
"LowLimit": null,
"DaysRange": "5769.67 - 5838.52",
"DaysRangeRealtime": "5769.67 - 5838.52",
"FiftydayMovingAverage": null,
"TwoHundreddayMovingAverage": null,
"ChangeFromTwoHundreddayMovingAverage": null,
"PercentChangeFromTwoHundreddayMovingAverage": null,
"ChangeFromFiftydayMovingAverage": null,
"PercentChangeFromFiftydayMovingAverage": null,
"Name": "FTSE 100",
"Notes": "-",
"Open": "5770.28",
"PreviousClose": "5770.28",
"PricePaid": null,
"ChangeinPercent": "+1.17%",
"PriceSales": null,
"PriceBook": null,
"ExDividendDate": "N/A",
"PERatio": null,
"DividendPayDate": "N/A",
"PERatioRealtime": null,
"PEGRatio": null,
"PriceEPSEstimateCurrentYear": null,
"PriceEPSEstimateNextYear": null,
"Symbol": "^FTSE",
"SharesOwned": null,
"ShortRatio": null,
"LastTradeTime": "5:20am",
"TickerTrend": "N/A",
"OneyrTargetPrice": null,
"Volume": "0",
"HoldingsValue": null,
"HoldingsValueRealtime": null,
"YearRange": "4790.04 - 5902.11",
"DaysValueChange": "- - +1.17%",
"DaysValueChangeRealtime": "- - +1.17%",
"StockExchange": "FSI",
"DividendYield": null,
"PercentChange": "+1.17%"
}
}
}
});
I have this this feed from Yahoo (YQL) and need to output some info to a webpage. Can someone help please. Thanks!! This is causing me severe headaches. lol
cbfunc({
"query": {
"count": "1",
"created": "2010-12-07T10:38:18Z",
"lang": "en-US",
"results": {
"quote": {
"symbol": "^FTSE",
"Ask": null,
"AverageDailyVolume": "0",
"Bid": null,
"AskRealtime": null,
"BidRealtime": null,
"BookValue": null,
"Change_PercentChange": "+67.33 - +1.17%",
"Change": "+67.33",
"Commission": null,
"ChangeRealtime": "+67.33",
"AfterHoursChangeRealtime": "N/A - N/A",
"DividendShare": null,
"LastTradeDate": "12/7/2010",
"TradeDate": null,
"EarningsShare": null,
"ErrorIndicationreturnedforsymbolchangedinvalid": "N/A",
"EPSEstimateCurrentYear": null,
"EPSEstimateNextYear": null,
"EPSEstimateNextQuarter": null,
"DaysLow": "5769.67",
"DaysHigh": "5838.52",
"YearLow": "4790.04",
"YearHigh": "5902.11",
"HoldingsGainPercent": "- - -",
"AnnualizedGain": "-",
"HoldingsGain": null,
"HoldingsGainPercentRealtime": "- - -",
"HoldingsGainRealtime": null,
"MoreInfo": "cnv",
"OrderBookRealtime": "N/A",
"MarketCapitalization": null,
"MarketCapRealtime": null,
"EBITDA": null,
"ChangeFromYearLow": null,
"PercentChangeFromYearLow": null,
"LastTradeRealtimeWithTime": "5:20am - <b>5837.61</b>",
"ChangePercentRealtime": "+67.33 - +1.17%",
"ChangeFromYearHigh": null,
"PercebtChangeFromYearHigh": null,
"LastTradeWithTime": "5:20am - <b>5837.61</b>",
"LastTradePriceOnly": "5837.61",
"HighLimit": null,
"LowLimit": null,
"DaysRange": "5769.67 - 5838.52",
"DaysRangeRealtime": "5769.67 - 5838.52",
"FiftydayMovingAverage": null,
"TwoHundreddayMovingAverage": null,
"ChangeFromTwoHundreddayMovingAverage": null,
"PercentChangeFromTwoHundreddayMovingAverage": null,
"ChangeFromFiftydayMovingAverage": null,
"PercentChangeFromFiftydayMovingAverage": null,
"Name": "FTSE 100",
"Notes": "-",
"Open": "5770.28",
"PreviousClose": "5770.28",
"PricePaid": null,
"ChangeinPercent": "+1.17%",
"PriceSales": null,
"PriceBook": null,
"ExDividendDate": "N/A",
"PERatio": null,
"DividendPayDate": "N/A",
"PERatioRealtime": null,
"PEGRatio": null,
"PriceEPSEstimateCurrentYear": null,
"PriceEPSEstimateNextYear": null,
"Symbol": "^FTSE",
"SharesOwned": null,
"ShortRatio": null,
"LastTradeTime": "5:20am",
"TickerTrend": "N/A",
"OneyrTargetPrice": null,
"Volume": "0",
"HoldingsValue": null,
"HoldingsValueRealtime": null,
"YearRange": "4790.04 - 5902.11",
"DaysValueChange": "- - +1.17%",
"DaysValueChangeRealtime": "- - +1.17%",
"StockExchange": "FSI",
"DividendYield": null,
"PercentChange": "+1.17%"
}
}
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
经过两天的绞尽脑汁,得到了答案。简直不敢相信。这是代码。这只是为了输出 FTSE 100 的 YQL 查询数据。感谢大家的回答!
Got the answer after 2 days of head wrecking. Can't believe it. Here is the code. It was just to output data from YQL query for the FTSE 100. Thanks for answering everyone!
jQuery.getJSON() :使用 GET HTTP 请求从服务器加载 JSON 编码的数据。
jQuery.parseJSON :采用格式良好的 JSON 字符串并返回生成的 JavaScript 对象。
jQuery.getJSON() : Load JSON-encoded data from the server using a GET HTTP request.
jQuery.parseJSON : Takes a well-formed JSON string and returns the resulting JavaScript object.
你到底想输出什么?如果这是字符串格式的有效 JSON 对象,您可以使用...
其中
JSON
是您从 Yahoo 接收的提要。然后您可以访问对象的属性,例如。
What are you trying to output exactly? If this is a valid JSON object in string format you can use...
Where
JSON
is the feed you are receiving from Yahoo.You can then access properties on the object eg.