packages feed

jsontsv 0.1.1.1 → 0.1.2.0

raw patch · 4 files changed

+44/−8 lines, 4 files

Files

Main.hs view
@@ -118,6 +118,10 @@       in case e of          Just e' -> evalKeyPath ks e'         Nothing -> Null+-- traverse array elements with additional keys+evalKeyPath ks@(Key key:_) (Array v) = +      let vs = V.toList v+      in String . mconcat . intersperse "," $ map (evalToText ks) vs evalKeyPath ((Index _):_) _ = Null evalKeyPath _ _ = Null 
README.md view
@@ -2,7 +2,8 @@  Transforms JSON objects into tab-separated line-oriented output, which is more convenient for downstream processing with Unix tools like `grep`, `awk`,-`diff`, etc., and for inspecting with spreadsheet programs. +`diff`, etc., and for inspecting with spreadsheet programs using a CSV output+option.  ## Synopsis @@ -31,12 +32,42 @@     "imdb": 8.9   } }+{+  "title": "Terminator 2: Judgement Day",+  "year": 1991,+  "stars": [+    {+      "name": "Arnold Schwarzenegger"+    },+    {+      "name": "Linda Hamilton"+    }+  ],+  "ratings": {+    "imdb": 8.5+  }+}+{+  "title": "Interstellar",+  "year": 2014,+  "stars": [+    {+      "name": "Matthew McConaughey"+    },+    {+      "name": "Anne Hathaway"+    }+  ],+  "ratings": {+    "imdb": 8.9+  }+} ```  Note that this input is not actually JSON at the top-level. It is a stream of JSON objects. It can be fed into `jsontsv`: -    jsontsv 'title year stars ratings.imdb' < input.json+    jsontsv 'title year stars.name ratings.imdb' < input.json  outputs this tab-separated text: @@ -47,7 +78,7 @@  You can pick off array elements using `[i]` syntax: -    jsontsv 'title year stars[0]' < input.json+    jsontsv 'title year stars[0].name' < input.json  outputs  @@ -118,3 +149,4 @@  * [jsawk](https://github.com/micha/jsawk)  * [jq][jq]+* [jsoncsv](https://github.com/gradus/jsoncsv)
example.json view
@@ -2,8 +2,8 @@   "title": "Terminator 2: Judgement Day",   "year": 1991,   "stars": [-    "Arnold Schwarzenegger",-    "Linda Hamilton"+    {"name": "Arnold Schwarzenegger"},+    {"name": "Linda Hamilton"}   ],   "ratings": {     "imdb": 8.5@@ -13,8 +13,8 @@   "title": "Interstellar",   "year": 2014,   "stars": [-    "Matthew McConaughey",-    "Anne Hathaway"+    {"name":"Matthew McConaughey"},+    {"name":"Anne Hathaway"}   ],   "ratings": {     "imdb": 8.9
jsontsv.cabal view
@@ -2,7 +2,7 @@ --  see http://haskell.org/cabal/users-guide/  name:                jsontsv-version:             0.1.1.1+version:             0.1.2.0 synopsis:            JSON to TSV transformer homepage:            https://github.com/danchoi/jsontsv description:         Transforms JSON into tab-separated line-oriented output, for easier processing in Unix-style pipelines.