From 7c0db32f643582fd529cd664200417d8ec1494da Mon Sep 17 00:00:00 2001 From: craigmj Date: Wed, 4 Mar 2015 17:08:10 +0200 Subject: [PATCH 1/3] Merged amrhassan changes and bumped version to 1.0 after 6 years --- doc/VERSION.txt | 6 +++--- json/json.lua | 4 ++-- json/rpc.lua | 4 ++-- json/rpcserver.lua | 4 ++-- json4lua-0.9.53-1.rockspec | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/VERSION.txt b/doc/VERSION.txt index 62435ac..deae881 100755 --- a/doc/VERSION.txt +++ b/doc/VERSION.txt @@ -1,4 +1,4 @@ JSON4Lua and JSONRPC4Lua -Version 0.9.30 -6 August 2009 -http://json.luaforge.net \ No newline at end of file +Version 1.0.0 +4 March 2015 +http://github.com/craigmj/json4lua/ \ No newline at end of file diff --git a/json/json.lua b/json/json.lua index 0d4fa4f..9ab4abd 100755 --- a/json/json.lua +++ b/json/json.lua @@ -2,8 +2,8 @@ -- JSON4Lua: JSON encoding / decoding support for the Lua language. -- json Module. -- Author: Craig Mason-Jones --- Homepage: http://json.luaforge.net/ --- Version: 0.9.40 +-- Homepage: http://github.com/craigmj/json4lua/ +-- Version: 1.0.0 -- This module is released under the MIT License (MIT). -- Please see LICENCE.txt for details. -- diff --git a/json/rpc.lua b/json/rpc.lua index 6182ae1..330b635 100755 --- a/json/rpc.lua +++ b/json/rpc.lua @@ -2,8 +2,8 @@ -- JSONRPC4Lua: JSON RPC client calls over http for the Lua language. -- json.rpc Module. -- Author: Craig Mason-Jones --- Homepage: http://json.luaforge.net/ --- Version: 0.9.40 +-- Homepage: http://github.com/craigmj/json4lua/ +-- Version: 1.0.0 -- This module is released under the MIT License (MIT). -- Please see LICENCE.txt for details. -- diff --git a/json/rpcserver.lua b/json/rpcserver.lua index abdaae5..e01f1f8 100755 --- a/json/rpcserver.lua +++ b/json/rpcserver.lua @@ -3,8 +3,8 @@ -- objects via http. -- json.rpcserver Module. -- Author: Craig Mason-Jones --- Homepage: http://json.luaforge.net/ --- Version: 0.9.40 +-- Homepage: http://github.com/craigmj/json4lua/ +-- Version: 1.0.0 -- This module is released under the MIT License (MIT). -- Please see LICENCE.txt for details. -- diff --git a/json4lua-0.9.53-1.rockspec b/json4lua-0.9.53-1.rockspec index 13af76f..b3b737a 100644 --- a/json4lua-0.9.53-1.rockspec +++ b/json4lua-0.9.53-1.rockspec @@ -1,8 +1,8 @@ package="JSON4Lua" -version="0.9.53-1" +version="1.0.0" source = { - url = "git://github.com/amrhassan/json4lua.git", - tag = "0.9.53-1" + url = "git://github.com/craigmj/json4lua.git", + tag = "1.0.0" } description = { summary = "JSON4Lua and JSONRPC4Lua implement JSON (JavaScript Object Notation) encoding and decoding and a JSON-RPC-over-http client for Lua.", @@ -15,7 +15,7 @@ description = { JSONRPC4Lua, which provides a simple JSON-RPC-over-http client and server (in a CGILua environment) for Lua. ]], - homepage = "http://json.luaforge.net/", + homepage = "http://github.com/craigmj/json4lua/", license = "GPL" } dependencies = { From 9dc2e3eb9c6609635734045b3302ea7206f8543d Mon Sep 17 00:00:00 2001 From: akaishi takeshi Date: Tue, 5 Jan 2016 03:57:50 +0900 Subject: [PATCH 2/3] assertion failed fixd --- examples/tests.lua | 2 +- json/json.lua | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/tests.lua b/examples/tests.lua index 999bec3..130aba3 100755 --- a/examples/tests.lua +++ b/examples/tests.lua @@ -185,7 +185,7 @@ function testJSON4Lua() -- Test json.null management t = { 1,2,json.null,4 } assert( json.encode(t)=="[1,2,null,4]" ) - t = {x=json.null } + t = {x=null } r = json.encode(t) assert( json.encode(t) == '{"x":null}' ) diff --git a/json/json.lua b/json/json.lua index 9ab4abd..c2d5ba0 100755 --- a/json/json.lua +++ b/json/json.lua @@ -137,7 +137,7 @@ function json.decode(s, startPos) return decode_scanString(s,startPos) end if string.sub(s,startPos,startPos+1)=='/*' then - return decode(s, decode_scanComment(s,startPos)) + return json.decode(s, decode_scanComment(s,startPos)) end -- Otherwise, it must be a constant return decode_scanConstant(s,startPos) @@ -161,6 +161,7 @@ end -- @param startPos The starting position for the scan. -- @return table, int The scanned array as a table, and the position of the next character to scan. function decode_scanArray(s,startPos) + local object = {} local array = {} -- The return value local stringLen = string.len(s) assert(string.sub(s,startPos,startPos)=='[','decode_scanArray called but array does not start at position ' .. startPos .. ' in string:\n'..s ) @@ -414,4 +415,4 @@ function isEncodable(o) return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null) end -return json \ No newline at end of file +return json From 44411b3acb7c3c8ce6249779ef7218b37903bf11 Mon Sep 17 00:00:00 2001 From: akaishi takeshi Date: Tue, 5 Jan 2016 04:56:14 +0900 Subject: [PATCH 3/3] lua5.1 table.foreach deprecated --- README.md | 9 ++++++--- examples/example.lua | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9890719..5979fe0 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,17 @@ print(json.encode({ 1, 2, 'fred', {first='mars',second='venus',third='earth'} }) json = require("json") testString = [[ { "one":1 , "two":2, "primes":[2,3,5,7] } ]] decoded = json.decode(testString) -table.foreach(decoded, print) +for key, item pairs(decoded) do + print(key, item) +end print ("Primes are:") -table.foreach(o.primes,print) +for key, item ipairs(decoded.primes) do + print(key, item) +end ``` ``` one 1 two 2 -primes table: 0032B928 Primes are: 1 2 2 3 diff --git a/examples/example.lua b/examples/example.lua index 36497da..b503fa9 100755 --- a/examples/example.lua +++ b/examples/example.lua @@ -18,6 +18,10 @@ print('JSON encoded test is: ' .. jsonTest) result = json.decode(jsonTest) print ("The decoded table result:") -table.foreach(result,print) +for key, item in pairs(result) do + print(key, item) +end print ("The decoded table result.three") -table.foreach(result.three, print) +for i, item in ipairs(result.three) do + print(i, item) +end