diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 05:59:42 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 05:59:42 -0800 |
commit | d9d527a65dd068e0a093ed94ad5effc13567a5e1 (patch) | |
tree | 389a48290c084887a85e43918971ebdfff2bc5f8 /table/path.go | |
parent | 40819efb0c592d8a23da8bec0006014b43321ac4 (diff) |
table: make table json prettier
Even 'jq' command makes the output very nicer.
$ curl http://localhost:8080/v1/bgp/neighbor/10.0.0.1/local-rib |jq '.'
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/path.go')
-rw-r--r-- | table/path.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/table/path.go b/table/path.go index 9b38bc44..635cbf5d 100644 --- a/table/path.go +++ b/table/path.go @@ -97,7 +97,6 @@ func (pd *PathDefault) MarshalJSON() ([]byte, error) { aslist = append(aslist, path.AS...) } } - asPath, _ := json.Marshal(aslist) var prefix net.IP var prefixLen uint8 @@ -110,7 +109,7 @@ func (pd *PathDefault) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Network string Nexthop string - AsPath string + AsPath []uint32 Metric string //origin string Best string @@ -118,7 +117,7 @@ func (pd *PathDefault) MarshalJSON() ([]byte, error) { Network: prefix.String() + "/" + fmt.Sprint(prefixLen), Nexthop: pd.nexthop.String(), Metric: fmt.Sprint(med), - AsPath: string(asPath), + AsPath: aslist, Best: fmt.Sprint(pd.isBest), }) } |