Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Gregory Eremin ef69dfedd3
7 years ago
buffer Buffer description 8 years ago
lexer Kifflom! 8 years ago
parser Kifflom! 7 years ago
.gitignore Add readme 8 years ago
README.md Kifflom! 7 years ago
main.go Kifflom! 8 years ago
test.json Handle errors (with care) 8 years ago



Kifflom is a (streaming) JSON parser that does not build any structures from the document, but returns specific values matched by given selectors instead.


Lets take this JSON description of fruits.

    "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:

cat test.json | kifflom -s ".bananas#0.weight .prices.*"
# .prices.* 25
# .prices.* 10
# .prices.* 40.5
# .prices.* <nil>
# Parse error! Yay!
# [010:036] (Error: Unexpected symbol: '!')
# .bananas#0.weight 5


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. A fellow father-brother can benefit from low and constant memory usage, although I don't think he would.

# Running lexer tests and benchmarks
cd lexer/
go test -bench .