MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / reindentJson

Function reindentJson

pkg/wconfig/settingsconfig.go:768–786  ·  view source on GitHub ↗
(barr []byte, indentStr string)

Source from the content-addressed store, hash-verified

766}
767
768func reindentJson(barr []byte, indentStr string) []byte {
769 if len(barr) < 2 {
770 return barr
771 }
772 if barr[0] != '{' && barr[0] != '[' {
773 return barr
774 }
775 if !bytes.Contains(barr, []byte("\n")) {
776 return barr
777 }
778 outputLines := bytes.Split(barr, []byte("\n"))
779 for i, line := range outputLines {
780 if i == 0 {
781 continue
782 }
783 outputLines[i] = append([]byte(indentStr), line...)
784 }
785 return bytes.Join(outputLines, []byte("\n"))
786}
787
788func jsonMarshalConfigInOrder(m waveobj.MetaMapType) ([]byte, error) {
789 if len(m) == 0 {

Callers 1

jsonMarshalConfigInOrderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected