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

Function tonum

gjson.go:577–598  ·  view source on GitHub ↗
(json string)

Source from the content-addressed store, hash-verified

575}
576
577func tonum(json string) (raw string, num float64) {
578 for i := 1; i < len(json); i++ {
579 // less than dash might have valid characters
580 if json[i] <= '-' {
581 if json[i] <= ' ' || json[i] == ',' {
582 // break on whitespace and comma
583 raw = json[:i]
584 num, _ = strconv.ParseFloat(raw, 64)
585 return
586 }
587 // could be a '+' or '-'. let's assume so.
588 } else if json[i] == ']' || json[i] == '}' {
589 // break on ']' or '}'
590 raw = json[:i]
591 num, _ = strconv.ParseFloat(raw, 64)
592 return
593 }
594 }
595 raw = json
596 num, _ = strconv.ParseFloat(raw, 64)
597 return
598}
599
600func tolit(json string) (raw string) {
601 for i := 1; i < len(json); i++ {

Callers 2

arrayOrMapMethod · 0.85
ParseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…