An open API service indexing awesome lists of open source software.

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

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)