json.load(file)

Load and decode a file containing JSON data.

Parameters

file

A File object or a filename string, representing the file whose content will be decoded from JSON.

Return value

Returns the corresponding Lua value or a nil value in case of error.

Example

local net = require "net" local json = require "json" print("Downloading dummy json file...") local http = await(net.Http("https://microsoftedge.github.io"):download("/Demos/json-dummy-data/64KB.json")) -- Checks that everything went right during download if http.response.file.exists then -- load users table from the download JSON file local users = json.load(http.response.file) for user in each(users) do print(user.name) end else error("Failed to load JSON file") end