问题
我们在linux明亮行中查看json数据的时候,有时候一个文件里面的JSON就是一整行,类似这样
[root@linux /home/root/canal.deployer-1.1.4/conf/tradeAndRefund 19:31:41]$ cat meta.dat
{"clientDatas":[{"clientIdentity":{"clientId":1001,"destination":"tradeAndRefund","filter":""},"cursor":{"identity":{"slaveId":-1,"sourceAddress":{"address":"dev01","port":3306}},"postion":{"gtid":"","included":false,"journalName":"mysql-bin.000060","position":416092207,"serverId":10,"timestamp":1608077088000}}}],"destination":"tradeAndRefund"}
[root@linux /home/root/canal.deployer-1.1.4/conf/tradeAndRefund 19:37:54]$
这个看起来很费劲!!!
解决
使用python的json.tool。一般安装了python的都会有这个模块,不用再额外安装。使用方式如下
[root@linux /home/root/canal.deployer-1.1.4/conf/tradeAndRefund 19:37:54]$ cat meta.dat | python -m json.tool
{
"clientDatas": [
{
"clientIdentity": {
"clientId": 1001,
"destination": "tradeAndRefund",
"filter": ""
},
"cursor": {
"identity": {
"slaveId": -1,
"sourceAddress": {
"address": "dev01",
"port": 3306
}
},
"postion": {
"gtid": "",
"included": false,
"journalName": "mysql-bin.000060",
"position": 416092207,
"serverId": 10,
"timestamp": 1608077088000
}
}
}
],
"destination": "tradeAndRefund"
}
看起来很清爽,问题解决~