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
13c9723d
Commit
13c9723d
authored
May 12, 2019
by
seny
Browse files
Fix docs
parent
2a6d96c8
Changes
2
Show whitespace changes
Inline
Side-by-side
README.md
View file @
13c9723d
JSON encoding/decoding
library
for Lua
JSON encoding/decoding
module
for Lua
=====================================
=
=====================================
[lua-json] provides fast JSON encoding/decoding routines for Lua:
[lua-json] provides fast JSON encoding/decoding routines for Lua:
-
Support for inline data transformation/filtering via metamethods/handlers.
-
Support for inline data transformation/filtering via metamethods/handlers.
-
Properly protected against memory allocation error
s.
-
Written in C with 32/64-bit awarenes
s.
-
No external dependencies.
-
No external dependencies.
-
Written in C.
### json.encode(value, [event])
### json.encode(value, [event])
...
@@ -119,11 +118,11 @@ assert(tostring(encode_decode(obj, '__toB', fromB)) == 'b')
...
@@ -119,11 +118,11 @@ assert(tostring(encode_decode(obj, '__toB', fromB)) == 'b')
```
```
Non-standard
numeric
values
Non-standard
JSON
values
------------------------
---
------------------------
[lua-json]
supports the following values in JSON:
`[-]nan`
,
`[-]NaN`
,
`[-]inf`
,
`[-]Infinity`
.
[lua-json]
recognizes numbers prefixed with
`0x`
as hexadecimal. It also supports the following values:
It also recognizes numbers prefixed with
`0x`
as hexadecimal
.
`[-]nan`
,
`[-]NaN`
,
`[-]inf`
,
`[-]Infinity`
.
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:
...
@@ -134,7 +133,7 @@ local json = require 'json'
...
@@ -134,7 +133,7 @@ local json = require 'json'
local function filter(t)
local function filter(t)
for k, v in pairs(t) do
for k, v in pairs(t) do
if v ~= v or v == 1/0 or v == -1/0 then
if v ~= v or v == 1/0 or v == -1/0 then
error(("
invali
d value '%f' at index '%s'"):format(v, k))
error(("
non-standar
d value '%f' at index '%s'"):format(v, k))
end
end
end
end
return t
return t
...
...
rockspec/lua-json-git-1.rockspec
View file @
13c9723d
...
@@ -4,13 +4,12 @@ source = {
...
@@ -4,13 +4,12 @@ source = {
url
=
'git://github.com/neoxic/lua-json.git'
,
url
=
'git://github.com/neoxic/lua-json.git'
,
}
}
description
=
{
description
=
{
summary
=
'JSON encoding/decoding
library
for Lua'
,
summary
=
'JSON encoding/decoding
module
for Lua'
,
detailed
=
[[
detailed
=
[[
lua
-
json
provides
fast
JSON
encoding
/
decoding
routines
for
Lua
:
lua
-
json
provides
fast
JSON
encoding
/
decoding
routines
for
Lua
:
-
Support
for
inline
data
transformation
/
filtering
via
metamethods
/
handlers
.
-
Support
for
inline
data
transformation
/
filtering
via
metamethods
/
handlers
.
-
Properly
protected
against
memory
allocation
error
s
.
-
Written
in
C
with
32
/
64
-
bit
awarenes
s
.
-
No
external
dependencies
.
-
No
external
dependencies
.
-
Written
in
C
.
]],
]],
license
=
'MIT'
,
license
=
'MIT'
,
homepage
=
'https://github.com/neoxic/lua-json'
,
homepage
=
'https://github.com/neoxic/lua-json'
,
...
...
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