If you want to restrict what keyrier-json can do on your system, you can run the AppImage in a sandbox like Firejail. Then double-click the AppImage in the file manager to open it. Use at your own risk!ĭownload the keyrier-json AppImage and make it executable using your file manager or by entering the following commands in a terminal: Follow these instructions only if you trust the developer of the software. This is a Linux security feature.īehold! AppImages are usually not verified by others. However, they need to be marked as executable before they can be run. Unlike other applications, AppImages do not need to be installed before they can be used. Running keyrier-json on Linux without installation Most AppImages run on recent versions of Arch Linux, CentOS, Debian, Fedora, openSUSE, Red Hat, Ubuntu, and other common desktop distributions. No system libraries or system preferences are altered. Download an application, make it executable, and run! No need to install. Awesome!ĪppImages are single-file applications that run on most Linux distributions. You may explore them on your own but these two are sufficient to do the job, which is to pretty print JSON files.Keyrier-json is available as an AppImage which means "one app = one file", which you can download and run on your Linux system while you don't need a package manager and nothing gets changed in your system. I know there are other ways to parse JSON file and print it in a proper format. If that’s the case, you can use it pretty print the JSON file in the terminal: python3 -m json.tool sample.json Pretty printing JSON with Python It’s more likely that you have Python installed on your system. You can also use cat and redirection if you want: cat pretty.json | jq -c Using Python to pretty print JSON file in Linux jq -c < pretty.json Minified JSON file display To minify a JSON file, you can use the compact option -c. Let’s take a reverse stance and minify a well-formatted JSON file. sample.json > pretty.json Pretty printing JSON file in Linux Terminal Bonus: Minify a JSON file with jq command If you want to modify the original JSON file with pretty print format, you can pipe the parsed output to a new file and then copy it to the original JSON file. You probably also know that you cannot redirect to the same file and the tee command is not guaranteed to work all the time. You probably already know how to redirect the command output to a file in Linux. Keep in mind that the above command will not impact the original JSON file. You may also tempt to use the cat command but I believe it is useless use of cat command. Once you have it installed, use it in the following manner to pretty print JSON file on the display: jq. With universe repository enabled, you can install it on Ubuntu using the apt command: sudo apt install jq You can use your distribution’s package manager to install it. I am not going into details about using jq command line tool here. You can use it to slice, filter, map and transform structured data. Pretty print JSON with jq command in Linux If you got a minified file, let me show you how to pretty print the JSON file in Linux terminal. However, things will be different if you are stuck to a terminal or want to do it in your shell script. You can use most text editors with some plugins to display it with proper formatting. I mean JSON files are supposed to read like this after all: Pretty Printed JSON is easier to read Even a human can still read it but if JSON file is properly formatted to display the content, it will be much easier. Take this for an example: Minified JSON is difficult to readĪ computer can easily read it. However, reading the JSON file can be a pain if the JSON file is minified. JSON files are awesome because they store collection of data in a human-readable format.
0 Comments
Leave a Reply. |