From ca9d198b6b646ef83260c8f5c3f4d909e2365ff2 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Thu, 26 Feb 2015 18:32:29 +0700 Subject: [PATCH] Add readme --- .gitignore | 2 +- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 4b54934..68ed6cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -main +kifflom big*.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..6f6b484 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# Kifflom! + +Kifflom is a (streaming) JSON parser that does not build any structures from the document, +but returns specific values matched by given selectors instead. + +## Example + +Lets take this JSON description of fruits. + +```json +{ + "prices": { + "apple": 25, + "banana": 10, + "peach": 40.5, + "pomelo": null + }, + "bananas": [ + {"length": 13, "weight": 5}, + {"length": 18, "weight": 8},! + {"length": 13, "weight": 4} + ] +} +``` + +In order to get the weight of the first banana and prices for all the fruits +we can use such a command: + +```bash +cat test.json | kifflom -s ".bananas#0.weight .prices.*" +# .prices.* 25 +# .prices.* 10 +# .prices.* 40.5 +# .prices.* +# +# Parse error! Yay! +# [010:036] (Error: Unexpected symbol: '!') +# .bananas#0.weight 5 +``` + +## Performance + +As you can learn from benchmarks described below, kifflom's lexer itself is +roughly 8.5 times slower than the standard JSON parser on any amount of data. +You can benefit from low and constant memory usage, although I don't think you would. + +```bash +# Running lexer tests and benchmarks +cd lexer/ +go test -bench . +```