Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
/ Json Public archive

Fast JSON binary module for LuaRT

License

Notifications You must be signed in to change notification settings

samyeyo/Json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON for LuaRT
Fast JSON binary module for LuaRT

LuaRT module Windows LuaRT license Twitter Follow

Features | Installation | Usage | Documentation | License

JSON project is now deprecated, as it is now part of the LuaRT distribution

🔹Features

  • JSON binary module for LuaRT
  • Decode JSON string representation to Lua value
  • Encode Lua value to JSON string representation
  • Based on zzzJSON, one of the fastest C JSON implementation

🔹Installation

Before using the JSON module, you must have been previously installed LuaRT to continue.

Method 1 : JSON module release package 📦

The preferred way to get the JSON module is to download the latest release package available on GitHub.
Just unpack the downloaded archive to get the Json.dll LuaRT binary module, and place it in the modules folder of your LuaRT installation. Be sure to download the right platform version as your LuaRT installation, either x86 or x64

Method 2 : JSON module from sources ⚙️

All you need to build the JSON module from sources is a valid installation of the Mingw-w64 distribution (actually tested using GCC 8.1 and GCC 12+), feedback is welcome for other C/C++ compilers.

First clone the JSON module repository (or manualy download the repository as ZIP file) :

git clone https://github.com/samyeyo/Json.git

Then go to the root directory of the repository and type make:

cd Json\
make

It will try to autodetect the LuaRT path and platform, and if it failed, you can still set the LUART_PATH directory in the Makefile.
If everything went right, it will produce the json.dll LuaRT binary module, and put a copy in your LuaRT modules\ folder.

🔹Usage

The LuaRT module can be used by any LuaRT interpreter, either luart.exe or wluart.exe
To use the LuaRT module in your applications, just require for the json module to load it :

Once loaded, the Json module can be used as in this script :

local json = require "json"

-- json.encode() : encode a Lua value to JSON string representation
print(json.encode({ "Hello", "World", { name = "LuaRT" } })) -- Prints '["Hello", "World", {"name": LuaRT} ]'

-- json.decode() : decode a JSON string representation to a Lua value
local data = json.decode('["Hello", "World", {"name": "LuaRT"} ]')
print(data[3].name) -- Prints LuaRT

Warning The json.dll binary module must be in the same directory as the Lua script that loads it, or in the current LUA_CPATH

🔹Documentation

🔹License

JSON for LuaRT is copyright (c) 2022 Samir Tine. JSON for LuaRT is open source, released under the MIT License.

See full copyright notice in the LICENSE file.