Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is keys() and o in this example code #1

Open
sant527 opened this issue Aug 31, 2020 · 2 comments
Open

what is keys() and o in this example code #1

sant527 opened this issue Aug 31, 2020 · 2 comments

Comments

@sant527
Copy link

sant527 commented Aug 31, 2020

can you explain what is keys() and o. Are they predefined.

$ echo '{"name":{"first":"Jason"},"age":25}' | jawk '{
	keys(o); for (k in o) print k, _[o[k],JSON]
}'
name {"first":"Jason"}
age 25

Where can i find full documentation.

But this is amazing project. looking for something like this

How can i install in archlinux

@mohd-akram
Copy link
Owner

mohd-akram commented Aug 31, 2020

jawk is the same as awk with the extra variable _ and the keys function. You can find the full awk documentation here or by doing man awk in your terminal. In awk, you do not have to define variables, they are immediately available for use. In this case o has no value, but when passed to the keys() function it fills it as an array (in awk, arrays are more like dictionaries). Then you can loop over the array/dictionary with for (k in o) and get the value with o[k].

To install you can just do sudo make install.

@sant527
Copy link
Author

sant527 commented Aug 31, 2020

Thank you for the explnation for it. I will check it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants