Fx is a command line tool for processing, viewing, and formatting JSON. It provides an interactive way to explore JSON data, apply transformations, and filter content using JavaScript expressions. This tutorial explains how to install Fx JSON viewer and processor on Ubuntu 24.04.
Install Fx
Download the executable to the /usr/local/bin
directory:
sudo wget -qO /usr/local/bin/fx https://github.com/antonmedv/fx/releases/latest/download/fx_linux_amd64
Set execute permission:
sudo chmod a+x /usr/local/bin/fx
We can check Fx version as follows:
fx --version
Testing Fx
Suppose we have JSON data saved in the test.json
file:
echo '{"status":"success","data":[{"name":"John","age":25},{"name":"James","age":29}]}' > test.json
The Fx tool offers various filters for processing JSON data. For instance, the dot (.
) filter displays the JSON as-is but in a well-formatted manner.
fx '.' test.json
Output:
{
"status": "success",
"data": [
{
"name": "John",
"age": 25
},
{
"name": "James",
"age": 29
}
]
}
We can extract a specific field from a JSON object or an element from a JSON array as shown below:
fx '.data[1].name' test.json
Output:
James
Uninstall Fx
To remove Fx, simply delete the associated file:
sudo rm -rf /usr/local/bin/fx
Leave a Comment
Cancel reply