I'd like to extract an elememt by "$". But it retrieves nothing (the 1st call of main.py). Does anybody know what is wrong? Thanks.
$ cat data.json
{
"id": {
"$": {
"view": "all",
"id": "sec4",
"role": "materials-methods"
}
}
}
$ cat main.py
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:
import sys
import json
json_data = json.load(sys.stdin)
import jsonpath_rw_ext
res = jsonpath_rw_ext.match(sys.argv[1], json_data)
for match in res:
print match.keys()
$ < data.json ./main.py '$."$"'
$ < data.json ./main.py '$."id"'
[u'$']