[ANN] json 0.1.0

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] json 0.1.0

Xpol Wan
json is a module that provide fast json APIs for lua.

It based on the RapidJSON ( [1]) library.

APIs included:

- `json.decode()` decode json to lua table.
- `json.encode()` encode lua table to json string.
- `json.load()` load json file into lua table.
- `json.dump()` dump lua table to json file.

It has tested with Lua 5.1 5.2 5.3 and LuaJIT 2.0 2.1 on Windows 7,  Linux (travis) and MacOS 10.10 [footnote].

Please visit GitHub project for source, documentation (in README.md), bug report and discussions:


It also have submitted to luarocks [2], just

> luarocks install json




--------------------------

[footnote]: for MacOS with Lua 5.2, the follow 2 test expected error in are not passed(no error raised):


Suggestion and help about the 2 test are welcomed!


Best Regards!

Xpol Wan
// There is a better way!
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Ignacio Burgueño-2
To be able to install it using LuaRocks (on Windows), we need the recent cmake patch, right? Even though I'm running from a VS command prompt, it wants to use MinGW.​
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Xpol Wan
Yes. I just send a pull request to lua rocks to make cmake works with msvc.
Ignacio Burgueño <[hidden email]>于2015年3月26日 周四03:51写道:
To be able to install it using LuaRocks (on Windows), we need the recent cmake patch, right? Even though I'm running from a VS command prompt, it wants to use MinGW.​
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Valerio
In reply to this post by Xpol Wan
hi,
in terms of raw performance, how does it compare with the lua-cjson library ? 



thanks,
Valerio

On Wed, Mar 25, 2015 at 9:10 AM, Xpol Wan <[hidden email]> wrote:
json is a module that provide fast json APIs for lua.

It based on the RapidJSON ( [1]) library.

APIs included:

- `json.decode()` decode json to lua table.
- `json.encode()` encode lua table to json string.
- `json.load()` load json file into lua table.
- `json.dump()` dump lua table to json file.

It has tested with Lua 5.1 5.2 5.3 and LuaJIT 2.0 2.1 on Windows 7,  Linux (travis) and MacOS 10.10 [footnote].

Please visit GitHub project for source, documentation (in README.md), bug report and discussions:


It also have submitted to luarocks [2], just

> luarocks install json




--------------------------

[footnote]: for MacOS with Lua 5.2, the follow 2 test expected error in are not passed(no error raised):


Suggestion and help about the 2 test are welcomed!


Best Regards!

Xpol Wan
// There is a better way!

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Xpol Wan
I have just add a simple test on Windows 7 with LuaJIT 2.0.3:

It seem: 

* json is faster when decoding (especially large data)
* cjson is faster when encoding data

but json have more feature when encoding (ordered keys, and try to do best detect for table types).

I'll add performance test in travis and appveyor later.

Detailed test result:

[rapidjson/bin/data/sample.json][1]:
json.decode()   1.3516025543213
cjson.decode()  2.2664051055908
json.encode()   2.2368049621582
cjson.encode()  1.3914031982422

[rapidjson/bin/data/webapp.json][2]:
json.decode()   2.4480056762695
cjson.decode()  2.6756038665771
json.encode()   2.6312065124512
cjson.encode()  2.0330047607422




On Mon, Mar 30, 2015 at 11:02 PM Valerio Schiavoni <[hidden email]> wrote:
hi,
in terms of raw performance, how does it compare with the lua-cjson library ? 



thanks,
Valerio

On Wed, Mar 25, 2015 at 9:10 AM, Xpol Wan <[hidden email]> wrote:
json is a module that provide fast json APIs for lua.

It based on the RapidJSON ( [1]) library.

APIs included:

- `json.decode()` decode json to lua table.
- `json.encode()` encode lua table to json string.
- `json.load()` load json file into lua table.
- `json.dump()` dump lua table to json file.

It has tested with Lua 5.1 5.2 5.3 and LuaJIT 2.0 2.1 on Windows 7,  Linux (travis) and MacOS 10.10 [footnote].

Please visit GitHub project for source, documentation (in README.md), bug report and discussions:


It also have submitted to luarocks [2], just

> luarocks install json




--------------------------

[footnote]: for MacOS with Lua 5.2, the follow 2 test expected error in are not passed(no error raised):


Suggestion and help about the 2 test are welcomed!


Best Regards!

Xpol Wan
// There is a better way!

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Nagaev Boris
On Tue, Mar 31, 2015 at 2:21 AM, Xpol Wan <[hidden email]> wrote:

> I have just add a simple test on Windows 7 with LuaJIT 2.0.3:
>
> It seem:
>
> * json is faster when decoding (especially large data)
> * cjson is faster when encoding data
>
> but json have more feature when encoding (ordered keys, and try to do best
> detect for table types).
>
> I'll add performance test in travis and appveyor later.
>
> Detailed test result:
>
> [rapidjson/bin/data/sample.json][1]:
> json.decode()   1.3516025543213
> cjson.decode()  2.2664051055908
> json.encode()   2.2368049621582
> cjson.encode()  1.3914031982422
>
> [rapidjson/bin/data/webapp.json][2]:
> json.decode()   2.4480056762695
> cjson.decode()  2.6756038665771
> json.encode()   2.6312065124512
> cjson.encode()  2.0330047607422
>
>
> [1]:https://github.com/xpol/json/blob/master/rapidjson/bin/data/sample.json
> [2]:https://github.com/xpol/json/blob/master/rapidjson/bin/data/webapp.json
>
>

Can you provide more details on "ordered keys, and try to do best
detect for table types". I think, order of keys does not matter either
for JSON objects or for Lua tables. What are table types detected by
json module?

Can you include cjon's encoding part into json?


Best regards,
Boris Nagaev

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Xpol Wan
New test result:

On windows:

This json module performance a bit slower than cjson when processing booleans nulls strings. but much faster than cjson when processing numbers.

On Linux (tested on Travis).

This json only module only a bit faster when encoding numbers.

"Ordered keys" means when this module encoding lua table as object.
Keys are sorted. But this is not true for the current developing version.
A `option.sort_keys` has added and default to false.

"detect for table types"

This json module support meta table field __jsontype to specify `"array"` or `"object"` types.


On Tue, Mar 31, 2015 at 10:55 PM Nagaev Boris <[hidden email]> wrote:
On Tue, Mar 31, 2015 at 2:21 AM, Xpol Wan <[hidden email]> wrote:
> I have just add a simple test on Windows 7 with LuaJIT 2.0.3:
>
> It seem:
>
> * json is faster when decoding (especially large data)
> * cjson is faster when encoding data
>
> but json have more feature when encoding (ordered keys, and try to do best
> detect for table types).
>
> I'll add performance test in travis and appveyor later.
>
> Detailed test result:
>
> [rapidjson/bin/data/sample.json][1]:
> json.decode()   1.3516025543213
> cjson.decode()  2.2664051055908
> json.encode()   2.2368049621582
> cjson.encode()  1.3914031982422
>
> [rapidjson/bin/data/webapp.json][2]:
> json.decode()   2.4480056762695
> cjson.decode()  2.6756038665771
> json.encode()   2.6312065124512
> cjson.encode()  2.0330047607422
>
>
> [1]:https://github.com/xpol/json/blob/master/rapidjson/bin/data/sample.json
> [2]:https://github.com/xpol/json/blob/master/rapidjson/bin/data/webapp.json
>
>

Can you provide more details on "ordered keys, and try to do best
detect for table types". I think, order of keys does not matter either
for JSON objects or for Lua tables. What are table types detected by
json module?

Can you include cjon's encoding part into json?


Best regards,
Boris Nagaev

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Xpol Wan
I think the better performance on windows is because the MSVC is slow when convert numbers <--> string.

On Wed, Apr 1, 2015 at 3:20 PM Xpol Wan <[hidden email]> wrote:
New test result:

On windows:

This json module performance a bit slower than cjson when processing booleans nulls strings. but much faster than cjson when processing numbers.

On Linux (tested on Travis).

This json only module only a bit faster when encoding numbers.

"Ordered keys" means when this module encoding lua table as object.
Keys are sorted. But this is not true for the current developing version.
A `option.sort_keys` has added and default to false.

"detect for table types"

This json module support meta table field __jsontype to specify `"array"` or `"object"` types.


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Nagaev Boris
In reply to this post by Xpol Wan
On Wed, Mar 25, 2015 at 8:10 AM, Xpol Wan <[hidden email]> wrote:

> json is a module that provide fast json APIs for lua.
>
> It based on the RapidJSON ( [1]) library.
>
> APIs included:
>
> - `json.decode()` decode json to lua table.
> - `json.encode()` encode lua table to json string.
> - `json.load()` load json file into lua table.
> - `json.dump()` dump lua table to json file.
>
> It has tested with Lua 5.1 5.2 5.3 and LuaJIT 2.0 2.1 on Windows 7,  Linux
> (travis) and MacOS 10.10 [footnote].
>
> Please visit GitHub project for source, documentation (in README.md), bug
> report and discussions:
>
> https://github.com/xpol/json
>
> It also have submitted to luarocks [2], just
>
>> luarocks install json
>
>
> [1]: https://github.com/miloyip/rapidjson
> [2]: http://rocks.moonscript.org/modules/xpol/json
>
>
> --------------------------
>
> [footnote]: for MacOS with Lua 5.2, the follow 2 test expected error in are
> not passed(no error raised):
>
> https://github.com/xpol/json/blob/v0.1.0/spec/json_dump_spec.lua#L64
> https://github.com/xpol/json/blob/v0.1.0/spec/json_dump_spec.lua#L70
>
> Suggestion and help about the 2 test are welcomed!
>
>
> Best Regards!
>
> Xpol Wan
> // There is a better way!

Your package conflicts with LuaJSON package "customizable JSON
decoder/encoder" [1] [2], which is one of the most popular Lua
packages according to [3]. This packages provides module "json" as
well as your package. That is why they can't be used together.

BTW, there are other Lua modules for JSON encoding/decoding: DKJSON,
Lua YAJL. I found comparison of modules DKJSON, Lua YAJL and cJSON
[4].


[1] https://github.com/harningt/luajson
[2] https://rocks.moonscript.org/modules/harningt/luajson
[3] http://lua-users.org/lists/lua-l/2015-02/msg00300.html
[4] http://www.kyne.com.au/~mark/software/lua-json-performance.html

Best regards,
Boris Nagaev

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] json 0.1.0

Xpol Wan
Thanks, I'll rename mine to rapidjson next release.

Nagaev Boris <[hidden email]>于2015年4月1日 周三17:28写道:

On Wed, Mar 25, 2015 at 8:10 AM, Xpol Wan <[hidden email]> wrote:
> json is a module that provide fast json APIs for lua.
>
> It based on the RapidJSON ( [1]) library.
>
> APIs included:
>
> - `json.decode()` decode json to lua table.
> - `json.encode()` encode lua table to json string.
> - `json.load()` load json file into lua table.
> - `json.dump()` dump lua table to json file.
>
> It has tested with Lua 5.1 5.2 5.3 and LuaJIT 2.0 2.1 on Windows 7,  Linux
> (travis) and MacOS 10.10 [footnote].
>
> Please visit GitHub project for source, documentation (in README.md), bug
> report and discussions:
>
> https://github.com/xpol/json
>
> It also have submitted to luarocks [2], just
>
>> luarocks install json
>
>
> [1]: https://github.com/miloyip/rapidjson
> [2]: http://rocks.moonscript.org/modules/xpol/json
>
>
> --------------------------
>
> [footnote]: for MacOS with Lua 5.2, the follow 2 test expected error in are
> not passed(no error raised):
>
> https://github.com/xpol/json/blob/v0.1.0/spec/json_dump_spec.lua#L64
> https://github.com/xpol/json/blob/v0.1.0/spec/json_dump_spec.lua#L70
>
> Suggestion and help about the 2 test are welcomed!
>
>
> Best Regards!
>
> Xpol Wan
> // There is a better way!

Your package conflicts with LuaJSON package "customizable JSON
decoder/encoder" [1] [2], which is one of the most popular Lua
packages according to [3]. This packages provides module "json" as
well as your package. That is why they can't be used together.

BTW, there are other Lua modules for JSON encoding/decoding: DKJSON,
Lua YAJL. I found comparison of modules DKJSON, Lua YAJL and cJSON
[4].


[1] https://github.com/harningt/luajson
[2] https://rocks.moonscript.org/modules/harningt/luajson
[3] http://lua-users.org/lists/lua-l/2015-02/msg00300.html
[4] http://www.kyne.com.au/~mark/software/lua-json-performance.html

Best regards,
Boris Nagaev