1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

new /x/jsonx and /x/mathx util sub-packages

This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-11-06 20:25:25 +02:00
parent 485395190b
commit 51fc2f35ca
9 changed files with 567 additions and 0 deletions

21
x/jsonx/jsonx.go Normal file
View File

@@ -0,0 +1,21 @@
package jsonx
import "bytes"
var (
quoteLiteral = '"'
emptyQuoteBytes = []byte(`""`)
nullLiteral = []byte("null")
)
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)
}