Git Product home page Git Product logo

rsjson's Introduction

rsjson

rsjson is a Rust library designed to be called from OpenResty Lua for JSON encoding and decoding. It provides a high-performance, safe, and easy-to-use solution for working with JSON data in Lua.

Features

  • High Performance: Written in Rust, rsjson is designed for speed.
  • Safety: Leverages Rust's strong type system and error handling.
  • Ease of Use: Simple API with only two methods, encode and decode.

Installation

Build the Rust Library

  1. Clone the repository and navigate to its directory.
  2. Run cargo build --release.
  3. The dynamic library (librsjson.so on Linux, librsjson.dylib on macOS) will be in the target/release directory.

Lua Bindings

Copy the rsjson.lua file to your OpenResty Lua project.

Usage

Here's a simple example demonstrating how to use rsjson:

local json = require('rsjson')

local json_string = '{"user": "demo", "debug": true, "unique_id": 123456, "meta": {"items": ["1","2","3"]}}'

-- Decode JSON string to Lua table
local doc = json.decode(json_string)
print(doc)

-- Encode Lua table to JSON string
print(json.encode(doc))

API

json.decode(json_string: string) -> table Decodes a JSON-formatted string and returns a Lua table.

json.encode(lua_table: table) -> string Encodes a Lua table into a JSON-formatted string.

Contributing

Feel free to open issues or pull requests if you have suggestions or improvements.

License

This project is licensed under the MIT License.

rsjson's People

Contributors

skitsanos avatar renovate[bot] avatar

Watchers

 avatar  avatar

rsjson's Issues

Retool build using mlua backend

Are you aware you don't have to do this two step dance requiring end users to cargo build then luarocks install but you can use the mlua build backend to directly allow LuaRocks to trigger the Rust build?

Is this something you'd be willing to accept as a contribution if I were to work up a PR?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

cargo
Cargo.toml
  • serde 1.0
  • serde_json 1.0
  • mlua 0.9.9
  • cc 1.0
  • bindgen 0.65.1
rsjson-lua54/Cargo.toml
rsjson-luajit/Cargo.toml
dockerfile
docker/Dockerfile
github-actions
.github/workflows/build.yml
  • actions/checkout v4
  • KyleMayes/install-llvm-action v2

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.