github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/internal/ekaenc/json.go (about) 1 // Copyright © 2020. All rights reserved. 2 // Author: Ilya Stroy. 3 // Contacts: iyuryevich@pm.me, https://github.com/qioalice 4 // License: https://opensource.org/licenses/MIT 5 6 package ekaenc 7 8 //goland:noinspection GoSnakeCaseUsage 9 const ( 10 NULL_JSON = `null` 11 ) 12 13 //goland:noinspection GoSnakeCaseUsage 14 var ( 15 NULL_JSON_BYTES_SLICE = []byte(NULL_JSON) 16 ) 17 18 // IsNullJSON returns true if b == nil or b[:4] == "null" (case insensitive). 19 func IsNullJSON(b []byte) bool { 20 21 if b == nil { 22 return true 23 } 24 25 z := len(b) == 4 26 z = z && b[0] == 'N' || b[0] == 'n' 27 z = z && (b[1] == 'U' || b[1] == 'u') 28 z = z && (b[2] == 'L' || b[2] == 'l') 29 z = z && (b[3] == 'L' || b[3] == 'l') 30 31 return z 32 }