Code Monkey home page Code Monkey logo

json2lua's Introduction

json2lua

This program converts JSON to Lua efficiently. Instead of parsing and loading the entire JSON data at once, which would cost quite some memory, it reads and processes the input in chunks.

Currently, the project comprises two components:

  • libenc, a small C++ library implementing encoding and decoding of text.
  • libjson2lua, a C++ library implementing a flexible, pull-style JSON-to-Lua parser and converter. It is kept in tree because it is developed for the program.
  • json2lua, the C++ program which exposes the required functionality to the command line.

In the future, the program might be expanded to support more encodings and, perhaps, to write bytecode directly.

Build

The Tup build system manages the process, which comprises three steps: configuration, build and testing.

Configuration

Parameters are specified in the usual way, in a tup.config file. You might be interested in using variants.

The steps are as follows:

  1. Choose an appropriate toolchain (CONFIG_TOOLCHAIN). Toolchains are defined in src/toolchains.tup.
  2. Fulfill the config items required or supported by the chosen toolchain (e.g. CONFIG_CXXFLAGS for the GNU toolchain).
  3. Choose appropriate values for toolchain-independent variables (like CONFIG_BUFFER_SIZE).

The provided tup.config contains the explanation of toolchain-independent variables.

Example configurations which may or may not be suitable for your build environment are provided in configs.tup. You could try to proceed to the build step by using one of them after adding your settings for the toolchain-independent parameters.

Build

The build step follows the standard procedure:

$  tup

Requirements

Testing

Tests are part of the build as well, and thus managed by Tup.

Tests have been implemented for the command-line program. As they involve a compiled executable, they can be carried out only if the target architecture for which the program was built matches that on which it was built. They will be run automatically if that's the case, and, if any of them fails, Tup will complain.

Usage

The accepted command-line depends on the version.

All versions admit the GNU standard to find it out:

$  json2lua --version

This prints json2lua something VERSION, where VERSION is the last token and represents the version.

Current version

The current version handles UTF-8-encoded JSON and outputs ASCII-encoded Lua 5.

The program shall be invoked as follows:

$  json2lua INPUT OUTPUT

INPUT and OUTPUT are the names of the files that shall be read and written, respectively.

json2lua's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

pengyunie

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.