(JS)完整的菜鸟,将* .json代码导入变量

时间:2018-09-15 18:59:09

标签: javascript json

因此,我尝试将.json文件代码导入到特定变量中,但是我不知道如何使用常规JavaScript来执行此操作。 例如,我想做:

foobar.json:

{
  "thingA": "foo",
  "thingB": "bar!"
}

和thing.js:

var hello = undefined; // get the json code here
console.log(hello.thingA + hello.thingB); // should output "foobar!"

0 个答案:

没有答案