ioke-json provides serialization and de-serialization to JSON for Ioke objects.
This is a proof of concept implementation. It evaluates JSON code as Ioke code which is DANGEROUS and should be used to parse trusted content only.
- Supports ikj only.
- Needs following patches to Ioke: http://github.com/bragi/ioke/tree/java_based_extensions, http://github.com/bragi/ioke/tree/dict_removeAt, http://github.com/bragi/ioke/tree/use_from_jar_file
Clone the repository in the same directory where you have ioke installed:
git clone git://github.com/bragi/ioke-json.git
You should have following directory structure:
ioke/
bin/
build/
...
ioke-json/
lib/
src/
...
Run ant:
ant
Extension will be built in ioke-json/lib/ioke-json-1.1.0.jar
Put ioke-json-1.1.0.jar in you load path. In you .ik file do:
use("ioke-json-1.1.0.jar")
Then following works:
true toJson # => "true"
"json" toJson # => "\"json\""
{0 => 1, "a" => "b"} toJson # => "{0 : 1, \"a\" : \"b\"}"
Origin mimic toJson # => "{\"kind\" : \"Origin\"}"
De-serialization is supported as well:
JSON fromText("[]") # => list
JSON fromText("{}") # => dict
JSON fromText("{\"kind\" : \"Origin\"}") # => {"kind" => "Origin"}
Thanks to Martin Elwin for creating to evaluation-based JSON parser: http://martin.elwin.com/blog/2009/01/simple-json-parser-in-ioke/
Current version is 1.1.0 released on 2009-06-23. See CHANGES.markdown for details.