github.com/mavryk-network/mvgo@v1.19.9/internal/compose/utils.go (about)

     1  // Copyright (c) 2024 Blockwatch Data Inc.
     2  // Author: alex@blockwatch.cc, abdul@blockwatch.cc
     3  
     4  package compose
     5  
     6  import (
     7  	"encoding/json"
     8  )
     9  
    10  func Json(v any, indent ...string) string {
    11  	var buf []byte
    12  	switch len(indent) {
    13  	case 0:
    14  		buf, _ = json.Marshal(v)
    15  	case 1:
    16  		buf, _ = json.MarshalIndent(v, "", indent[0])
    17  	default:
    18  		buf, _ = json.MarshalIndent(v, indent[0], indent[1])
    19  	}
    20  	return string(buf)
    21  }