Skip to content

Commit 695ea59

Browse files
author
Noboru Saito
committed
Added support for JSON input.
1 parent 965747f commit 695ea59

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

README.md

+55-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.org/noborus/trdsql.svg?branch=master)](https://travis-ci.org/noborus/trdsql)
44

5-
A tool that can execute SQL queries on CSV and [LTSV](http://ltsv.org/).
5+
A tool that can execute SQL queries on CSV, [LTSV](http://ltsv.org/) and JSON.
66

77
It is a tool like [q](https://github.com/harelba/q) , [textql](https://github.com/dinedal/textql) and others.
88

@@ -161,7 +161,60 @@ name:Apple price:100 id:3
161161

162162
**Note:** LTSV does not keep the output order of the columns
163163

164-
### JSON (output only)
164+
### JSON
165+
166+
For JSON files, specify option -ijson.
167+
168+
sample.json
169+
```JSON
170+
[
171+
{
172+
"id": "1",
173+
"name": "Orange",
174+
"price": "50"
175+
},
176+
{
177+
"id": "2",
178+
"name": "Melon",
179+
"price": "500"
180+
},
181+
{
182+
"id": "3",
183+
"name": "Apple",
184+
"price": "100"
185+
}
186+
]
187+
```
188+
189+
```sh
190+
$ trdsql -iltsv "SELECT * FROM sample.json"
191+
```
192+
193+
```CSV
194+
1,Orange,50
195+
2,Melon,500
196+
3,Apple,100
197+
```
198+
Another json format. One record is JSON.
199+
200+
sample2.json
201+
```JSON
202+
{
203+
"id": "1",
204+
"name": "Orange",
205+
"price": "50"
206+
}
207+
{
208+
"id": "2",
209+
"name": "Melon",
210+
"price": "500"
211+
}
212+
{
213+
"id": "3",
214+
"name": "Apple",
215+
"price": "100"
216+
}
217+
```
165218

166219
Output JSON with option -ojson.
167220

0 commit comments

Comments
 (0)