3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 j
= json
.load(sys
.stdin
)
11 components
= sys
.argv
[1].split("/")
14 def next_match(json_fragment
, components
):
15 if len(components
) == 0:
18 component
= components
[0]
19 if type(json_fragment
) == list:
21 for item
in json_fragment
:
22 yield from next_match(item
, components
[1:])
24 component
= int(component
)
25 if component
>= len(j
):
27 yield from next_match(json_fragment
[component
], components
[1:])
28 elif type(json_fragment
) == dict:
30 for key
in sorted(json_fragment
.keys()):
31 yield from next_match(json_fragment
[key
], components
[1:])
32 elif component
not in json_fragment
:
35 yield from next_match(json_fragment
[component
], components
[1:])
38 for match
in list(next_match(j
, components
)):
39 if type(match
) == dict:
40 print(" ".join(match
.keys()))