Skip to content

Commit 98356da

Browse files
committed
initial release
0 parents  commit 98356da

154 files changed

Lines changed: 3734 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Void (cryon.io)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# hjson-lua
2+
A lightweight H/JSON library for Lua
3+
4+
Ported from [hjson-py](https://github.com/hjson/hjson-py). Inspired by rxi - [json.lua](https://github.com/rxi/json.lua).

hjson.lua

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-- MIT License - Copyright (c) 2019 Void (cryon.io)
2+
3+
local decoder = require"hjson.decoder"
4+
local encoder = require"hjson.encoder"
5+
local encoderH = require"hjson.encoderH"
6+
7+
local _decoder
8+
local _encoder
9+
local _encoderH
10+
11+
function decode(str)
12+
if not _decoder then
13+
_decoder = decoder:new()
14+
end
15+
return _decoder:decode(str)
16+
end
17+
18+
function encode_json(str)
19+
if not _encoder then
20+
_encoder = encoder:new()
21+
end
22+
return _encoder:encode(str)
23+
end
24+
25+
function encode(str)
26+
if not _encoderH then
27+
_encoderH = encoderH:new()
28+
end
29+
return _encoderH:encode(str)
30+
end
31+
32+
hjson = {
33+
encode = encode,
34+
stringify = encode,
35+
encode_to_json = encode_json,
36+
stringify_to_json = encode_json,
37+
decode = decode,
38+
parse = decode
39+
}
40+
41+
return hjson

0 commit comments

Comments
 (0)