V
V
Vitaly Melnikov2019-07-21 19:41:12
bash
Vitaly Melnikov, 2019-07-21 19:41:12

How to format JSON output from GITHUB via bash?

I get the standard json of my repositories via the github api, the output is an array of the form:
[
{
"id": 1296269,
"name": "Hello-World",
"full_name": "octocat/Hello-World",
...
"created_at ": "2011-01-26T19:01:12Z",
"updated_at": "2011-01-26T19:14:43Z",
...
},
{
"id": 1296270,
"name": "Hello-World2" ",
"full_name": "octocat/Hello-World2",
...
"created_at": "2011-01-26T19:01:12Z",
"updated_at": "2011-01-26T19:14:43Z",
...
}
]
I want to get line-by-line output with formatting, in the spirit of
Repository: Hello-World === Created: 2011-01-26 at 19:01:12
Repository: Hello-World2 === Created: 2011-01-26 at 19:01:12
Well, or simply
Hello-World 2011- 01-26T19:01:12Z
Hello-World2 2011-01-26T19:01:12Z
What I managed to do myself:
jq '.[] | [.name, .created_at]'
At the output I get arrays
[
"Hello-World",
"2017-05-18T14:39:47Z"
]
[
"Hello-World2",
"2017-12-26T12:27:11Z"
]
...
Is it possible to improve the issue?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2019-07-22
@Vmelnikoff

varJson='[
{
"id": 1296269,
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"created_at": "2011-01-26T19:01:12Z",
"updated_at": "2011-01-26T19:14:43Z"
},
{
"id": 1296270,
"name": "Hello-World2",
"full_name": "octocat/Hello-World2",
"created_at": "2011-01-26T19:01:12Z",
"updated_at": "2011-01-26T19:14:43Z"
}
]'

Hello-World 2011-01-26T19:01:12Z
Hello-World2 2011-01-26T19:01:12Z

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question