https://github.com/nleiva/yangson
Adds and removes indentation to JSON files
https://github.com/nleiva/yangson
cisco-ios-xr golang json yang
Last synced: about 2 months ago
JSON representation
Adds and removes indentation to JSON files
- Host: GitHub
- URL: https://github.com/nleiva/yangson
- Owner: nleiva
- Created: 2017-02-26T22:39:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-11T16:08:24.000Z (about 9 years ago)
- Last Synced: 2025-10-07T20:44:46.752Z (8 months ago)
- Topics: cisco-ios-xr, golang, json, yang
- Language: C++
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yangson
## Synopsis
Add and removes indentation to **YANG** config files **JSON** encoded.
## Code Example
`prettyprint` takes a compact JSON config and pretty prints it.
- input: [compact JSON](files/bgp.json)
- output: [pretty printed JSON](files/bgp_formatted.json)
```go
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](files/bgp_formatted.json)
- output: [compact JSON](files/bgp.json)
```go
b, err := ioutil.ReadFile("files/bgp_formatted.json")
if err != nil {
fmt.Print(err)
}
b, _ = unprettyprint(b)
```
## Where are we taking these JSON config files from?
- Check out this great example: [YDK bgp_xr_json](https://github.com/CiscoDevNet/ydk-cpp/tree/master/core/samples/bgp_xr_json)
- We will include further YDK samples here: [ydk-cpp-samples](ydk-cpp-samples)
## To Do list
- Incorporate commit/push configs on ([github.go](github.go))
- Add suport to clone or Wget/cURL a config ([github.go](github.go))
## See it in action
- [Go Playground](https://play.golang.org/p/TUdaIF_NBp)