MCPcopy Index your code
hub / github.com/tidwall/gjson / modPretty

Function modPretty

gjson.go:2973–2992  ·  view source on GitHub ↗

@pretty modifier makes the json look nice.

(json, arg string)

Source from the content-addressed store, hash-verified

2971
2972// @pretty modifier makes the json look nice.
2973func modPretty(json, arg string) string {
2974 if len(arg) > 0 {
2975 opts := *pretty.DefaultOptions
2976 Parse(arg).ForEach(func(key, value Result) bool {
2977 switch key.String() {
2978 case "sortKeys":
2979 opts.SortKeys = value.Bool()
2980 case "indent":
2981 opts.Indent = cleanWS(value.String())
2982 case "prefix":
2983 opts.Prefix = cleanWS(value.String())
2984 case "width":
2985 opts.Width = int(value.Int())
2986 }
2987 return true
2988 })
2989 return bytesString(pretty.PrettyOptions(stringBytes(json), &opts))
2990 }
2991 return bytesString(pretty.Pretty(stringBytes(json)))
2992}
2993
2994// @this returns the current element. Can be used to retrieve the root element.
2995func modThis(json, arg string) string {

Callers

nothing calls this directly

Calls 8

ParseFunction · 0.85
cleanWSFunction · 0.85
bytesStringFunction · 0.85
stringBytesFunction · 0.85
ForEachMethod · 0.80
BoolMethod · 0.80
IntMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…