北城已荒凉 2017-06-27 12:17 采纳率: 0%
浏览 35

奇怪的JSON键

{
  "Meta Data": {
    "1: Symbol": "MSFT",
    "2: Indicator": "Triple Exponential Moving Average (TEMA)",
    "3: Last Refreshed": "2017-06-26 16:00:00",
    "4: Interval": "15min",
    "5: Time Period": 10,
    "6: Series Type": "close",
    "7: Time Zone": "US/Eastern"
}
}

Let me first start off by saying that I just started learning JSON and AJAX, so this may sound like a stupid question. Recentely though, I found this JSON output text. But there a couple of problems I have with it. First of all, some keys have two words in them, without a _ . How can you then use them in javascript? I mean you cannot have a method with a space in it, right? And my second problem is related to the first problem, since there are also some keys that even start out like this 1: or 2: . What's up with that? So if anyone can show me how I can for example reach the "5: time period" key in javascript, that would be a huge help.

  • 写回答

2条回答 默认 最新

  • weixin_33728708 2017-06-27 12:19
    关注

    The keys in this case are just strings, so you would access them using strings. Assuming you've loaded this JSON into a val variable, you could use

    val["Meta Data"]["1: Symbol"]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计