MarshalDocIndent is like MarshalDoc but produces indented output for JSON.
(format Format, doc *NetworkTrafficDoc)
| 110 | |
| 111 | // MarshalDocIndent is like MarshalDoc but produces indented output for JSON. |
| 112 | func MarshalDocIndent(format Format, doc *NetworkTrafficDoc) ([]byte, error) { |
| 113 | switch format { |
| 114 | case FormatJSON: |
| 115 | jsonDoc, err := DocToJSON(doc) |
| 116 | if err != nil { |
| 117 | return nil, err |
| 118 | } |
| 119 | return json.MarshalIndent(jsonDoc, "", " ") |
| 120 | default: |
| 121 | return yamlLib.Marshal(doc) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | // UnmarshalDoc deserializes bytes into a NetworkTrafficDoc from the specified format. |
| 126 | // For YAML, it unmarshals directly. |
no test coverage detected