-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.jq
64 lines (60 loc) · 1.18 KB
/
.jq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
def yamlify:
(objects | to_entries[] | (.value | type) as $type |
if $type == "array" then
"\(.key):", (.value | yamlify)
elif $type == "object" then
"\(.key):", " \(.value | yamlify)"
else
"\(.key):\t\(.value)"
end
)
// (arrays | select(length > 0)[] | [yamlify] |
" - \(.[0])", " \(.[1:][])"
)
// .
;
def rmnulls:
walk(
if type == "array" then
map(select(. != null))
elif type == "object" then
with_entries(
select(
.value != null and
.value != "" and
.value != [] and
.value != {}
)
)
else
.
end
);
def rmidx:
walk(
if type == "object" and has("indices") then
del(.indices)
elif type == "object" and has("display_text_range") then
del(.display_text_range)
else
.
end
);
def rmjunk:
del(.display_text_range,
.truncated,
.id,
.in_reply_to_status_id,
.in_reply_to_user_id,
.contributors,
.favorited,
.retweeted,
.retweeted_status.id,
.quoted_status_id,
.quoted_status.id,
.quoted_status.quoted_status_id,
.quoted_status.conversation_id,
.conversation_id,
.user.user_id,
.user_id
);