在Shell脚本中读取JSON文件

时间:2019-05-11 13:54:18

标签: shell enterprisedb

我有一个JSON文件,如下所示:

{"nodes":{"10.174.131.57":{"type":"Master","agent":"UP","db":"UP","vip":"","vip_active":false,"xlog":"D\/A3000D40","xloginfo":""},"10.174.131.58":{"type":"Idle","agent":"UP","db":"UNKNOWN","vip":"","vip_active":false,"xlog":"UNKNOWN","xloginfo":"Connection to 10.174.131.58:5444 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP\/IP connections."},"10.174.131.59":{"type":"Standby","agent":"UP","db":"UP","vip":"","vip_active":false,"xlog":"D\/A3000D40","xloginfo":""}},"allowednodes":["10.174.131.57","10.174.131.58","10.174.131.59"],"membershipcoordinator":"10.174.131.57","failoverpriority":["10.174.131.59"],"minimumstandbys":0,"missingnodes":[],"messages":[]}

我想将每个节点组件存储在变量中,然后比较它们之间的差异: 例如:

{"nodes":{"10.174.131.57":{"type":"Master","agent":"UP","db":"UP" ==> for this node, all these data should get stored on a set of variables.
"10.174.131.58":{"type":"Idle","agent":"UP","db":"UNKNOWN","vip":"","vip_active":false,"xlog":
==> this will get stored on a another set of variables.. and so on, and  then I'll compare if they are equal or not.

或者,如果有人可以给出一个非常简单的过程来使该文件可以被Shell脚本理解,那么它将很有帮助。

0 个答案:

没有答案
相关问题