MCPcopy
hub / github.com/tidwall/gjson / String

Method String

gjson.go:79–107  ·  view source on GitHub ↗

String returns a string representation of the value.

()

Source from the content-addressed store, hash-verified

77
78// String returns a string representation of the value.
79func (t Result) String() string {
80 switch t.Type {
81 default:
82 return ""
83 case False:
84 return "false"
85 case Number:
86 if len(t.Raw) == 0 {
87 // calculated result
88 return strconv.FormatFloat(t.Num, 'f', -1, 64)
89 }
90 var i int
91 if t.Raw[0] == '-' {
92 i++
93 }
94 for ; i < len(t.Raw); i++ {
95 if t.Raw[i] < '0' || t.Raw[i] > '9' {
96 return strconv.FormatFloat(t.Num, 'f', -1, 64)
97 }
98 }
99 return t.Raw
100 case String:
101 return t.Str
102 case JSON:
103 return t.Raw
104 case True:
105 return "true"
106 }
107}
108
109// Bool returns an boolean representation.
110func (t Result) Bool() bool {

Callers 4

TestBasicFunction · 0.95
TimeMethod · 0.95
parseArrayFunction · 0.95
GetFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestBasicFunction · 0.76