tangled
alpha
login
or
join now
atscan.net
/
plcbundle-go
1
fork
atom
[DEPRECATED] Go implementation of plcbundle
1
fork
atom
overview
issues
pulls
pipelines
pretty print json in op cmd
tree.fail
4 months ago
52d734d4
dc3ea2a9
+14
-4
1 changed file
expand all
collapse all
unified
split
cmd
plcbundle
commands
op.go
+14
-4
cmd/plcbundle/commands/op.go
···
314
314
fmt.Printf("\n")
315
315
}
316
316
317
317
-
// Verbose: show full JSON
317
317
+
// Verbose: show full JSON (pretty-printed)
318
318
if verbose {
319
319
fmt.Printf("Raw JSON\n")
320
320
fmt.Printf("────────\n")
321
321
+
322
322
+
var data []byte
321
323
if len(op.RawJSON) > 0 {
322
322
-
fmt.Println(string(op.RawJSON))
324
324
+
// Parse and re-format the raw JSON
325
325
+
var temp interface{}
326
326
+
if err := json.Unmarshal(op.RawJSON, &temp); err == nil {
327
327
+
data, _ = json.MarshalIndent(temp, "", " ")
328
328
+
} else {
329
329
+
// Fallback to raw if parse fails
330
330
+
data = op.RawJSON
331
331
+
}
323
332
} else {
324
324
-
data, _ := json.MarshalIndent(op, "", " ")
325
325
-
fmt.Println(string(data))
333
333
+
data, _ = json.MarshalIndent(op, "", " ")
326
334
}
335
335
+
336
336
+
fmt.Println(string(data))
327
337
fmt.Printf("\n")
328
338
}
329
339