从jQuery或JS中的json对象提取数据

从jQuery或JS中的json对象提取数据,第1张

从jQuery或JS中的json对象提取数据
var obj = [{    "disclaimer": "This data is collected from various providers and provided free of charge for informational purposes only, with no guarantee whatsoever of accuracy, validity, availability, or fitness for any purpose; use at your own risk. Other than that, have fun! More info: http://openexchangerates.org/terms/",    "license": "Data collected from various providers with public-facing APIs; copyright may apply; not for resale; no warranties given. Full license info: http://openexchangerates.org/license/",    "timestamp": 1339036116,    "base": "USD",    "rates": {        "EUR": 0.795767,        "GBP": 0.645895,        "JPY": 79.324997,        "USD": 1    }}];obj[0].rates.EUR; // output: 0.795767

要么

obj[0].rates['EUR']; output: //0.795767

演示

如果要在另一个变量中隔离费率并使用该变量,请尝试如下 *** 作:

var rates = obj[0].rates;

现在,

rates.EUR;rates.GBP;

等等。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5477654.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存