MCPcopy Index your code
hub / github.com/cortexlabs/cortex / JSONNumberToIntOrFloat

Function JSONNumberToIntOrFloat

pkg/lib/cast/interface.go:378–392  ·  view source on GitHub ↗
(in interface{})

Source from the content-addressed store, hash-verified

376}
377
378func JSONNumberToIntOrFloat(in interface{}) (interface{}, bool) {
379 number, ok := in.(json.Number)
380 if !ok {
381 return in, true
382 }
383 inInt, err := number.Int64()
384 if err == nil {
385 return inInt, true
386 }
387 inFloat, err := number.Float64()
388 if err == nil {
389 return inFloat, true
390 }
391 return nil, false
392}
393
394func JSONNumber(in interface{}) interface{} {
395 number, ok := in.(json.Number)

Callers 7

InterfaceToInt8DowncastFunction · 0.85
InterfaceToInt16DowncastFunction · 0.85
InterfaceToInt32DowncastFunction · 0.85
InterfaceToIntDowncastFunction · 0.85
InterfaceToInt64DowncastFunction · 0.85
InterfaceToFloat32Function · 0.85
InterfaceToFloat64Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected