json

版本 v0.1.3·更新於 2024-04-17

Exposes json.lua as a module using lovely

模組介紹 作者原文

This is a package mirror of rxi's json.lua with an added lovely patch

The provided lovely patch adds it under the module name "json". A modified extract from the project's original readme follows...

A lightweight JSON library for Lua

Usage

json = require "json"

The library provides the following functions:

json.encode(value)

Returns a string representing value encoded in JSON.

json.encode({ 1, 2, 3, { x = 10 } }) -- Returns '[1,2,3,{"x":10}]'

json.decode(str)

Returns a value representing the decoded JSON string.

json.decode('[1,2,3,{"x":10}]') -- Returns { 1, 2, 3, { x = 10 } }

Notes

  • Trying to encode values which are unrepresentable in JSON will never result

in type conversion or other magic: sparse arrays, tables with mixed key types

or invalid numbers (NaN, -inf, inf) will raise an error

  • null values contained within an array or object are converted to nil and

are therefore lost upon decoding

Pretty* encoding is not supported, json.encode() only encodes to a compact

format

License

This library is free software; you can redistribute it and/or modify it under

the terms of the MIT license. See LICENSE for details.

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。 這類模組需要先安裝社群載入器(包內 readme 通常會提供下載入口)。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

lovely

檔案與校驗

檔案名稱
json-0.1.3.zip
檔案大小
14.2 KiB