@@ -13,7 +13,10 @@ The difference from these tools is that the syntax of PostgreSQL or MySQL can be
13
13
## INSTALL
14
14
15
15
```
16
- go get -u github.com/noborus/trdsql
16
+ go get -d github.com/noborus/trdsql
17
+ cd $GOPATH/src/github.com/noborus/trdsql
18
+ make
19
+ make install
17
20
```
18
21
Or download binaries from the [ releases] ( https://github.com/noborus/trdsql/releases ) page(Linux/Windows/macOS).
19
22
@@ -216,6 +219,50 @@ $ trdsql -ijson "SELECT * FROM sample.json"
216
219
3,Apple,100
217
220
```
218
221
222
+ JSON can contain structured types, but trdsql is stored as it is as JSON string.
223
+
224
+ sample2.json
225
+ ``` JSON
226
+ [
227
+ {
228
+ "id" : 1 ,
229
+ "name" : " Drolet" ,
230
+ "attribute" : { "country" : " Maldives" , "color" : " burlywood" }
231
+ },
232
+ {
233
+ "id" : 2 ,
234
+ "name" : " Shelly" ,
235
+ "attribute" : { "country" : " Yemen" , "color" : " plum" }
236
+ },
237
+ {
238
+ "id" : 3 ,
239
+ "name" : " Tuck" ,
240
+ "attribute" : { "country" : " Mayotte" , "color" : " antiquewhite" }
241
+ }
242
+ ]
243
+ ```
244
+
245
+ ``` sh
246
+ trdsql -ijson " SELECT * FROM sample2.json"
247
+ ```
248
+
249
+ ``` CSV
250
+ 1,Drolet,"{""color"":""burlywood"",""country"":""Maldives""}"
251
+ 2,Shelly,"{""color"":""plum"",""country"":""Yemen""}"
252
+ 3,Tuck,"{""color"":""antiquewhite"",""country"":""Mayotte""}"
253
+ ```
254
+
255
+ Please use SQL function.
256
+
257
+ ``` sh
258
+ trdsql -ijson " SELECT id, name, JSON_EXTRACT(attribute,'$country '), JSON_EXTRACT(attribute,'$color ') FROM sample2.json"
259
+ ```
260
+ ``` CSV
261
+ 1,Drolet,Maldives,burlywood
262
+ 2,Shelly,Yemen,plum
263
+ 3,Tuck,Mayotte,antiquewhite
264
+ ```
265
+
219
266
Another json format. One record is JSON.
220
267
221
268
sample2.json
@@ -237,6 +284,7 @@ sample2.json
237
284
}
238
285
```
239
286
287
+
240
288
-ojson is JSON Output.
241
289
242
290
``` sh
@@ -292,7 +340,7 @@ trdsql -oraw -od "\t|\t" -db pdb "SELECT * FROM test.csv"
292
340
```
293
341
294
342
295
- ### ASCII Table & MarkDown ( output only)
343
+ ### ASCII Table & MarkDown output
296
344
297
345
-oat is ASCII table output.
298
346
It uses [ tablewriter] ( https://github.com/olekukonko/tablewriter ) .
@@ -326,7 +374,7 @@ $ trdsql -omd "SELECT * FROM test.csv"
326
374
| 3 | Apple |
327
375
```
328
376
329
- ### Vertical format
377
+ ### Vertical format output
330
378
331
379
-ovf is Vertical format output("column name | value" vertically).
332
380
0 commit comments