From 9af9be956d1fed82cde12e0a8932aa2fe3002680 Mon Sep 17 00:00:00 2001 From: jstrong Date: Wed, 11 Mar 2020 03:25:01 +0000 Subject: [PATCH] Update 'get-json-key.py' --- get-json-key.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/get-json-key.py b/get-json-key.py index 5be6494..ac4a37e 100755 --- a/get-json-key.py +++ b/get-json-key.py @@ -5,6 +5,9 @@ USAGE: [stdin] | ./get-json-key.py [KEY].. KEY can be a string key (object) or integer index (array), the program will try both + +Example: `echo '{"abc":[null,{"zzz":"hello world"}]}' | ./get-json-key.py abc 1 zzz` # -> hello world + """ import fileinput, sys, json, functools @@ -30,10 +33,9 @@ def main(keys: List[str]) -> None: raise e print(val) + if __name__ == '__main__': if len(sys.argv) < 2: print(HELP, file=sys.stderr) sys.exit(1) - main(sys.argv[1:]) - - + main(sys.argv[1:]) \ No newline at end of file