MCPcopy Index your code
hub / github.com/buger/jsonparser / ParseBoolean

Function ParseBoolean

parser.go:1325–1334  ·  view source on GitHub ↗

ParseBoolean parses a Boolean ValueType into a Go bool (not particularly useful, but here for completeness) SYS-REQ-012, SYS-REQ-036, SYS-REQ-057, SYS-REQ-066

(b []byte)

Source from the content-addressed store, hash-verified

1323// ParseBoolean parses a Boolean ValueType into a Go bool (not particularly useful, but here for completeness)
1324// SYS-REQ-012, SYS-REQ-036, SYS-REQ-057, SYS-REQ-066
1325func ParseBoolean(b []byte) (bool, error) {
1326 switch {
1327 case bytes.Equal(b, trueLiteral):
1328 return true, nil
1329 case bytes.Equal(b, falseLiteral):
1330 return false, nil
1331 default:
1332 return false, MalformedValueError
1333 }
1334}
1335
1336// ParseString parses a String ValueType into a Go string (the main parsing work is unescaping the JSON string)
1337// SYS-REQ-014, SYS-REQ-038, SYS-REQ-060, SYS-REQ-063, SYS-REQ-067

Callers 7

TestParseHelperNilSafetyFunction · 0.85
FuzzParseBoolFunction · 0.85
TestParseBooleanFunction · 0.85
GetBooleanFunction · 0.85
TestParseBooleanEmptyFunction · 0.85

Calls

no outgoing calls

Tested by 5

TestParseHelperNilSafetyFunction · 0.68
TestParseBooleanFunction · 0.68
TestParseBooleanEmptyFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…