In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how to use json.tool, a powerful Python tool under Linux. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
Linux users often need to view some data in the terminal, read from the file or the network protocol to obtain the data and view. For example, look at the json data in the file; for example, look at the data stored in etcd.
If you look directly at the data obtained by cat or curl, it will be very painful if the format is confused, and the json.tool of Python can format the data in the terminal.
Such as: cat json.file | python-m json.tool
Usage and examples
# Terminal operation. Vim json.file # writes the following: {"code": 0, "data": "fine", "error": "success"}
What cat json.file sees at this point is:
{"code": 0, "data": "fine", "error": "success"}
Whatever is written in it, so be it!
Try using this tool at this time
# Terminal executes cat json.file | python-m json.tool # will see something like this: {"code": 0, "data": "fine", "error": "success"}
Next, try to check the data of etcd.
# curl directly: curl localhost:2379/v2/keys # get this {"action": "get", "node": {"dir": true, "nodes": [{"key": "/ NSQMetaData", "dir": true, "modifiedIndex": 5, "createdIndex": 5}, {"key": "/ b2c_systech_nsq", "dir": true, "modifiedIndex": 6726335, "createdIndex": 6726335}, {"key": "/ hello", "value": "world" "modifiedIndex": 4, "createdIndex": 4}]} # plus tool curl localhost:2379/v2/keys | python-m json.tool # get this {"action": "get", "node": {"dir": true, "nodes": [{"createdIndex": 5, "dir": true, "key": "/ NSQMetaData", "modifiedIndex": 5}, {"createdIndex": 6726335, "dir": true "key": "/ b2c_systech_nsq", "modifiedIndex": 6726335}, {"createdIndex": 4, "key": "/ hello", "modifiedIndex": 4, "value": "world"}]}}
It can be seen that this gadget is still very helpful in the terminal environment and is worth learning.
The above is how to use json.tool, a powerful Python tool under Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.