Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Lua Json
Commits
86e5afd3
Commit
86e5afd3
authored
May 11, 2019
by
seny
Browse files
Fix docs
parent
99e6ae99
Changes
2
Show whitespace changes
Inline
Side-by-side
README.md
View file @
86e5afd3
JSON encoding/decoding library for Lua
JSON encoding/decoding library for Lua
======================================
======================================
[lua-json] provides the following API:
[lua-json] provides fast JSON encoding/decoding routines for Lua:
-
Support for inline data transformation/filtering via metamethods/handlers.
-
Properly protected against memory allocation errors.
-
No external dependencies.
-
Written in C.
### json.encode(value, [event])
### json.encode(value, [event])
Returns a text string containing a JSON representation of
`value`
. Optional
`event`
may be used
Returns a text string containing a JSON representation of
`value`
. Optional
`event`
may be used
...
@@ -115,12 +120,11 @@ assert(tostring(encode_decode(obj, '__toB', fromB)) == 'b')
...
@@ -115,12 +120,11 @@ assert(tostring(encode_decode(obj, '__toB', fromB)) == 'b')
```
```
Extended JSON
Non-standard numeric values
-------------
-------------
--------------
[lua-json] accepts non-standard numeric values
`[-]nan`
,
`[-]NaN`
,
`[-]inf`
,
`[-]Infinity`
when encoding
[lua-json] supports the following values in JSON:
`[-]nan`
,
`[-]NaN`
,
`[-]inf`
,
`[-]Infinity`
.
or decoding (if supported by the system). It also recognizes numbers prefixed with
`0x`
as hexadecimal
It also recognizes numbers prefixed with
`0x`
as hexadecimal.
when decoding.
If strictly compliant JSON generation is preferred, the following technique may be used to filter out
If strictly compliant JSON generation is preferred, the following technique may be used to filter out
these values:
these values:
...
@@ -140,14 +144,14 @@ end
...
@@ -140,14 +144,14 @@ end
local mt = {__toJSON = check}
local mt = {__toJSON = check}
local t = {
local t = {
good
= 1.234,
val
= 1.234,
nan = 0/0,
nan = 0/0,
inf = 1/0,
inf = 1/0,
ninf = -1/0,
ninf = -1/0,
}
}
local s = [[{
local s = [[{
"
good
": 1.234,
"
val
": 1.234,
"nan": nan,
"nan": nan,
"inf": inf,
"inf": inf,
"ninf": -inf
"ninf": -inf
...
...
rockspec/lua-json-git-1.rockspec
View file @
86e5afd3
...
@@ -5,6 +5,13 @@ source = {
...
@@ -5,6 +5,13 @@ source = {
}
}
description
=
{
description
=
{
summary
=
'JSON encoding/decoding library for Lua'
,
summary
=
'JSON encoding/decoding library for Lua'
,
detailed
=
[[
lua
-
json
provides
fast
JSON
encoding
/
decoding
routines
for
Lua
:
-
Support
for
inline
data
transformation
/
filtering
via
metamethods
/
handlers
.
-
Properly
protected
against
memory
allocation
errors
.
-
No
external
dependencies
.
-
Written
in
C
.
]],
license
=
'MIT'
,
license
=
'MIT'
,
homepage
=
'https://github.com/neoxic/lua-json'
,
homepage
=
'https://github.com/neoxic/lua-json'
,
maintainer
=
'Arseny Vakhrushev <arseny.vakhrushev@gmail.com>'
,
maintainer
=
'Arseny Vakhrushev <arseny.vakhrushev@gmail.com>'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment