tried using jql
PythonCoderUnicorn opened this issue · comments
Hello,
I used brew install
and have a sample.json file inside my folder directory. I was trying the commands as shown on the README, but could not get any data returned or get "unable to parse input".
my JSON
{
"employee": {
"name":"employee01",
"age": "30",
"city":"New York"
},
"boss" : {
"name": "boss person",
"role": "regional supervisor"
},
"stuff" : {
"a": 1,
"b": 2,
"c": 3
}
}
the commands i tried:
jql "boss" sample.json
among variationsjql "stuff{'a'}" sample.json
jql employee -s -r sample.json
jsql "employee['city']" -s -r sample.json
all of these return "unable to parse"
what am i doing wrong here?
You're almost there, it's just a matter of single / double quotes usage. Basically jql
is very strict about JSON keys and always needs key selectors to be double-quoted (https://github.com/yamafaktory/jql?tab=readme-ov-file#%EF%B8%8F-usage).
In your examples, it should like:
jql '"boss"' sample.json
{
"name": "boss person",
"role": "regional supervisor"
}
jql '"stuff""a"' sample.json
1
Please notice that in the last example, there's no need to have a .
between keys.
Then using the -s
flag is not really useful here since it's basically continuously reading the any command you would pipe in like docker logs with the --follow
flag (https://github.com/yamafaktory/jql?tab=readme-ov-file#read-a-stream-of-json-data-line-by-line).
Finally the -r
flag is only useful if you pick a string primitive via your selectors and want to strip the double quotes (https://github.com/yamafaktory/jql?tab=readme-ov-file#write-to-stdout-without-json-double-quotes).
I hope that it will help :) .
@yamafaktory
Thank you for your reply. I ran your examples and it worked. 🎉
Thanks for the tool.
Glad it helped!
Closing the issue then.