Add and removes indentation to YANG config files JSON encoded.
prettyprint
takes a compact JSON config and pretty prints it.
- input: compact JSON
- output: pretty printed JSON
b, err := ioutil.ReadFile("files/bgp.json")
if err != nil {
fmt.Print(err)
}
b, _ = prettyprint(b)
unprettyprint
takes an indented JSON config and pretty prints it.
- input: pretty printed JSON
- output: compact JSON
b, err := ioutil.ReadFile("files/bgp_formatted.json")
if err != nil {
fmt.Print(err)
}
b, _ = unprettyprint(b)
- Check out this great example: YDK bgp_xr_json
- We will include further YDK samples here: ydk-cpp-samples