diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2017-02-04 13:50:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-04 13:50:34 +0100 |
commit | 42f669beab39df38d2f4955b651541272126a04e (patch) | |
tree | f68d918629725f9306698bf0641910d1f714714b /lualibs-util-jsn.lua | |
parent | 144f6d16fd79bd0496b3ae379b69227e0d9bbfa9 (diff) | |
parent | 1b2f8c0355210dbfd34b10ed4ff7f0c90fda062d (diff) | |
download | lualibs-master.tar.gz |
v2.5
Diffstat (limited to 'lualibs-util-jsn.lua')
-rw-r--r-- | lualibs-util-jsn.lua | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lualibs-util-jsn.lua b/lualibs-util-jsn.lua index bbe25d8..e835c07 100644 --- a/lualibs-util-jsn.lua +++ b/lualibs-util-jsn.lua @@ -64,18 +64,19 @@ local jnumber = (1-whitespace-rparent-rbrace-comma)^1 / tonumber local key = jstring local jsonconverter = { "value", - object = lbrace * Cf(Ct("") * V("pair") * (comma * V("pair"))^0,rawset) * rbrace, - pair = Cg(optionalws * key * optionalws * colon * V("value")), - array = Ct(lparent * V("value") * (comma * V("value"))^0 * rparent), - value = optionalws * (jstring + V("object") + V("array") + jtrue + jfalse + jnull + jnumber + #rparent) * optionalws, + hash = lbrace * Cf(Ct("") * (V("pair") * (comma * V("pair"))^0 + optionalws),rawset) * rbrace, + pair = Cg(optionalws * key * optionalws * colon * V("value")), + array = Ct(lparent * (V("value") * (comma * V("value"))^0 + optionalws) * rparent), +-- value = optionalws * (jstring + V("hash") + V("array") + jtrue + jfalse + jnull + jnumber + #rparent) * optionalws, + value = optionalws * (jstring + V("hash") + V("array") + jtrue + jfalse + jnull + jnumber) * optionalws, } -- local jsonconverter = { "value", --- object = lbrace * Cf(Ct("") * V("pair") * (comma * V("pair"))^0,rawset) * rbrace, --- pair = Cg(optionalws * V("string") * optionalws * colon * V("value")), --- array = Ct(lparent * V("value") * (comma * V("value"))^0 * rparent), --- string = jstring, --- value = optionalws * (V("string") + V("object") + V("array") + jtrue + jfalse + jnull + jnumber) * optionalws, +-- hash = lbrace * Cf(Ct("") * (V("pair") * (comma * V("pair"))^0 + optionalws),rawset) * rbrace, +-- pair = Cg(optionalws * V("string") * optionalws * colon * V("value")), +-- array = Ct(lparent * (V("value") * (comma * V("value"))^0 + optionalws) * rparent), +-- string = jstring, +-- value = optionalws * (V("string") + V("hash") + V("array") + jtrue + jfalse + jnull + jnumber) * optionalws, -- } -- lpeg.print(jsonconverter) -- size 181 @@ -156,3 +157,5 @@ end -- inspect(tmp) -- inspect(json.tostring(true)) + +return json |