mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
28 lines
461 B
Go
28 lines
461 B
Go
package jsonx
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
)
|
|
|
|
var (
|
|
quoteLiteral = '"'
|
|
emptyQuoteBytes = []byte(`""`)
|
|
nullLiteral = []byte("null")
|
|
|
|
// ErrInvalid is returned when the value is invalid.
|
|
ErrInvalid = errors.New("invalid")
|
|
)
|
|
|
|
func isNull(b []byte) bool {
|
|
return len(b) == 0 || bytes.Equal(b, nullLiteral)
|
|
}
|
|
|
|
func trimQuotesFunc(r rune) bool {
|
|
return r == quoteLiteral
|
|
}
|
|
|
|
func trimQuotes(b []byte) []byte {
|
|
return bytes.TrimFunc(b, trimQuotesFunc)
|
|
}
|