JSON+Javascript/jQuery. How to import data from a json file and parse it?

前端 未结 7 2073
猫巷女王i
猫巷女王i 2021-01-31 19:12

If I have a JSON file named names.json with:

{\"employees\":[
    {\"firstName\":\"Anna\",\"lastName\":\"Meyers\"},
    {\"firstNam         


        
7条回答
  •  难免孤独
    2021-01-31 19:57

    For those sent here by Google after the fall of JQuery, use Fetch API

    fetch("test.json").then(async (resp) => {
      const asObject = await resp.json();
      console.log(asObject);
    })
    

提交回复
热议问题