Answers for "get json from file"

1

parse local json file

// pure javascript
let object;
let httpRequest = new XMLHttpRequest(); // asynchronous request
httpRequest.open("GET", "local/path/file.json", true);
httpRequest.send();
httpRequest.addEventListener("readystatechange", function() {
    if (this.readyState === this.DONE) {
      	// when the request has completed
        object = JSON.parse(this.response);
    }
});
Posted by: Guest on November-18-2020
2

read file json

with open('file.txt', 'r') as f:
	data = f.read()
Posted by: Guest on May-21-2021

Code answers related to "get json from file"

Code answers related to "Javascript"

Browse Popular Code Answers by Language