json.save(file)

Encode a Lua value to a JSON representation string and save it to a file.

Parameters

file

A File object or a filename string, representing the file to save the JSON data.

Return value

Returns true or false in case of error.

Example

local json = require "json" local t = {name = "John", age = 30, car: "null"} -- save table content to a file as JSON, should be {"name":"John", "age":30, "car":null} json.save("test.json", t)