“jq” is a command based on the JSON processor.
It allows you to convert, slice, map, filter, or perform other operations on JSON data.
By default, jq reads JSON entities (e.g. numbers, letters) from stdin.
You can use spaces to separate entities like 1 and 2 or true and false.
In this tutorial you will learn how to install jq on Ubuntu, test it or uninstall it.
- How to install jq on Ubuntu
- How to test jq on Ubuntu
- How to Uninstall jq on Ubuntu
How to install jq on Ubuntu
To install jq on Ubuntu, you need to run the following commands respectively, “sudo apt update”, “sudo apt install -y jq” and “jq –version” (optional).
Step 1: Download package information from all configured sources
sudo apt update
Step 2: Install jq on Ubuntu
sudo apt install -y jq
Step 3: Check jq . version
jq –version
Source: Ubuntu Manual.
How to test jq on Ubuntu
1. Sample JSON data
echo ‘{“status”:”success”,”data”:[{“name”:”Tom”,”age”:21},{“name”:”Mary”,”age”:24}]}’ > test.json
2. Sign “.” well-formed JSON print filter
jq’.’ test.json
3. Output of command
{ “status”: “success”, “data”: [
{
“name”: “Tom”,
“age”: 21
},
{
“name”: “Mary”,
“age”: 24
}
]
}
4. Retrieve a specific JSON object/element
jq ‘.data[1].name’ test.json
5. Output of command
“Maria Mother”
How to Uninstall jq on Ubuntu
To uninstall jq on Ubuntu, you need to run the following command, “sudo apt purge –autoremove -y jq”.
How to uninstall jq:
sudo apt purge –autoremove -y jq
read more
What is LD_LIBRARY_PATH?
How to fix “python: cannot open file ‘manage.py’: [Errno 2] No file or directory”
How to fix “TypeError: object ‘type’ cannot be registered”
Categories: How to
Source: thpttranhungdao.edu.vn/en/