github.com/zerosnake0/jzon@v0.0.9-0.20230801092939-1b135cb83f7f/iterator_bool.go (about) 1 package jzon 2 3 // ReadBool reads a boolean value 4 func (it *Iterator) ReadBool() (bool, error) { 5 c, err := it.nextToken() 6 if err != nil { 7 return false, err 8 } 9 switch c { 10 case 't': 11 it.head++ 12 return true, it.expectBytes("rue") 13 case 'f': 14 it.head++ 15 return false, it.expectBytes("alse") 16 default: 17 return false, UnexpectedByteError{got: c, exp: 't', exp2: 'f'} 18 } 19 }