Por ejemplo, tenemos un archivo JSON:

http://dummy.restapiexample.com/api/v1/employees

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
dieciséis
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
sesenta y cinco
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
{
"status":"success",
"data":[
{
"id":"1",
"employee_name":"Tiger Nixon",
"employee_salary":"320800",
"employee_age":"61",
"profile_image":""
},
{
"id":"2",
"employee_name":"Garrett Winters",
"employee_salary":"170750",
"employee_age":"63",
"profile_image":""
},
{
"id":"3",
"employee_name":"Ashton Cox",
"employee_salary":"86000",
"employee_age":"66",
"profile_image":""
},
{
"id":"4",
"employee_name":"Cedric Kelly",
"employee_salary":"433060",
"employee_age":"22",
"profile_image":""
},
{
"id":"5",
"employee_name":"Airi Satou",
"employee_salary":"162700",
"employee_age":"33",
"profile_image":""
},
{
"id":"6",
"employee_name":"Brielle Williamson",
"employee_salary":"372000",
"employee_age":"61",
"profile_image":""
},
{
"id":"7",
"employee_name":"Herrod Chandler",
"employee_salary":"137500",
"employee_age":"59",
"profile_image":""
},
{
"id":"8",
"employee_name":"Rhona Davidson",
"employee_salary":"327900",
"employee_age":"55",
"profile_image":""
},
{
"id":"9",
"employee_name":"Colleen Hurst",
"employee_salary":"205500",
"employee_age":"39",
"profile_image":""
},
{
"id":"10",
"employee_name":"Sonya Frost",
"employee_salary":"103600",
"employee_age":"23",
"profile_image":""
},
{
"id":"11",
"employee_name":"Jena Gaines",
"employee_salary":"90560",
"employee_age":"30",
"profile_image":""
},
{
"id":"12",
"employee_name":"Quinn Flynn",
"employee_salary":"342000",
"employee_age":"22",
"profile_image":""
},
{
"id":"13",
"employee_name":"Charde Marshall",
"employee_salary":"470600",
"employee_age":"36",
"profile_image":""
},
{
"id":"14",
"employee_name":"Haley Kennedy",
"employee_salary":"313500",
"employee_age":"43",
"profile_image":""
},
{
"id":"15",
"employee_name":"Tatyana Fitzpatrick",
"employee_salary":"385750",
"employee_age":"19",
"profile_image":""
},
{
"id":"16",
"employee_name":"Michael Silva",
"employee_salary":"198500",
"employee_age":"66",
"profile_image":""
},
{
"id":"17",
"employee_name":"Paul Byrd",
"employee_salary":"725000",
"employee_age":"64",
"profile_image":""
},
{
"id":"18",
"employee_name":"Gloria Little",
"employee_salary":"237500",
"employee_age":"59",
"profile_image":""
},
{
"id":"19",
"employee_name":"Bradley Greer",
"employee_salary":"132000",
"employee_age":"41",
"profile_image":""
},
{
"id":"20",
"employee_name":"Dai Rios",
"employee_salary":"217500",
"employee_age":"35",
"profile_image":""
},
{
"id":"21",
"employee_name":"Jenette Caldwell",
"employee_salary":"345000",
"employee_age":"30",
"profile_image":""
},
{
"id":"22",
"employee_name":"Yuri Berry",
"employee_salary":"675000",
"employee_age":"40",
"profile_image":""
},
{
"id":"23",
"employee_name":"Caesar Vance",
"employee_salary":"106450",
"employee_age":"21",
"profile_image":""
},
{
"id":"24",
"employee_name":"Doris Wilder",
"employee_salary":"85600",
"employee_age":"23",
"profile_image":""
}
]
}

Guardamos en: http://jsonstore.top/?13tfpim0

jq es un procesador JSON de línea de comandos ligero y flexible.

Página de inicio: https://stedolan.github.io/jq/

jqes como sed de datos JSON - se puede utilizar para cortar y filtro y el mapa y transformar los datos estructurados con la misma facilidad que sedawkgrepy los amigos que pueda tocar con el texto.

Instalar jq en CentOS

1
yum install jq -y

Resultado:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
dieciséis
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[root@tutorialspots ~]# yum install jq -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                     |  32 kB     00:00
 * base: mirror.alpix.eu
 * epel: mirror.imt-systems.com
 * extras: linux.darkpenguin.net
 * updates: linux.darkpenguin.net
base                                                     | 3.6 kB     00:00
extras                                                   | 2.9 kB     00:00
ius                                                      | 1.3 kB     00:00
nodesource                                               | 2.5 kB     00:00
updates                                                  | 2.9 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package jq.x86_64 0:1.6-2.el7 will be installed
--> Finished Dependency Resolution
 
 
Dependencies Resolved
 
================================================================================
 Package        Arch               Version               Repository        Size
================================================================================
Installing:
 jq             x86_64             1.6-2.el7             epel             167 k
 
Transaction Summary
================================================================================
Install  1 Package
 
Total download size: 167 k
Installed size: 381 k
Downloading packages:
jq-1.6-2.el7.x86_64.rpm                                    | 167 kB   00:15
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : jq-1.6-2.el7.x86_64                                          1/1
  Verifying  : jq-1.6-2.el7.x86_64                                          1/1
 
Installed:
  jq.x86_64 0:1.6-2.el7
 
Complete!

Para imprimir el objeto completo, use jq .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
dieciséis
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
sesenta y cinco
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
[root@tutorialspots ~]# curl -s http://dummy.restapiexample.com/api/v1/employees | jq .
{
  "status": "success",
  "data": [
    {
      "id": "1",
      "employee_name": "Tiger Nixon",
      "employee_salary": "320800",
      "employee_age": "61",
      "profile_image": ""
    },
    {
      "id": "2",
      "employee_name": "Garrett Winters",
      "employee_salary": "170750",
      "employee_age": "63",
      "profile_image": ""
    },
    {
      "id": "3",
      "employee_name": "Ashton Cox",
      "employee_salary": "86000",
      "employee_age": "66",
      "profile_image": ""
    },
    {
      "id": "4",
      "employee_name": "Cedric Kelly",
      "employee_salary": "433060",
      "employee_age": "22",
      "profile_image": ""
    },
    {
      "id": "5",
      "employee_name": "Airi Satou",
      "employee_salary": "162700",
      "employee_age": "33",
      "profile_image": ""
    },
    {
      "id": "6",
      "employee_name": "Brielle Williamson",