-1

I have the following json file which is generated as a result of some python code . (I basically transfer a dict into a json file)

{"workers dwell time": [{"Arham": 0.0}, {"Fayyaz Bhai": 3.28}, {"Khan sahab": 2.14}, {"Osama": 0.0}, {"Yasir (paadri)": 0.0}]}

The json file is named as workers_dwell_time_final.json

I want to import this file into javascript. And assign the names to the respective times in table.

Mainly i want to know how to import the json file into javascript ?

Osama
  • 55
  • 1
  • 4
  • 2
    Possible duplicate of [Load local JSON file into variable](https://stackoverflow.com/questions/14484613/load-local-json-file-into-variable) – xmaster May 07 '19 at 09:08
  • Possible duplicate of a million other questions and articles on google. – Alex May 07 '19 at 09:09
  • if you expect changes in the JSON file better not to import but read it. – AZ_ May 07 '19 at 09:11

1 Answers1

-1

data.json content
const data = [{"name" : "lily", "address" : "location street"}];

and use

<script type="text/javascript" src="data.json"></script>

also
use XMLHttpRequest read local json file