ostap/comp — pull request #10 by julochrobak (2013-07-13 18:11:07+00:00)
Title: supporting JSON input files

This change allows to load both tab-delimited and JSON files. It is only supported to load JSON files where every array contains elements of the same type:
* objects must have the same attributes
* string, numbers and booleans are considered equal

Valid inputs:

[ 1, 2, "hello world" ]
[ {"id": 1}, {"id": 2} ]
[ [1,2], [] ]
[ {"elems": []}, {"elems": [{}]} ]

Invalid inputs:

[ 1, {} ]
[ [], {} ]
[ {"id": 1}, {"name": ""} ]
[ {"elems": [1]}, {"elems": [{}]} ]

Example with a single object on the top level:

$ cat tennis.json
{"name":"tennis",
"type":"FeatureCollection",
"features":[
{"type":"Feature",
"geometry":{"type":"Point","coordinates":[8.57099155101007,47.350064305313]},
"properties":{
"City": "Zürich",
"Address":"Bleulerstrasse 41",
"Tel":"044 381 13 13",
"Name":"Tennis Lengg"}}]
}

and the query:

[ a.properties | a <- tennis.features, a.geometry.type == "Point" ]