MCPcopy Create free account
hub / github.com/francoispqt/gojay / Float32Key

Method Float32Key

encode_number_float.go:307–323  ·  view source on GitHub ↗

Float32Key adds a float32 to be encoded, must be used inside an object as it will encode a key

(key string, v float32)

Source from the content-addressed store, hash-verified

305
306// Float32Key adds a float32 to be encoded, must be used inside an object as it will encode a key
307func (enc *Encoder) Float32Key(key string, v float32) {
308 if enc.hasKeys {
309 if !enc.keyExists(key) {
310 return
311 }
312 }
313 enc.grow(10 + len(key))
314 r := enc.getPreviousRune()
315 if r != '{' {
316 enc.writeByte(',')
317 }
318 enc.writeByte('"')
319 enc.writeStringEscape(key)
320 enc.writeByte('"')
321 enc.writeByte(':')
322 enc.buf = strconv.AppendFloat(enc.buf, float64(v), 'f', -1, 32)
323}
324
325// Float32KeyOmitEmpty adds a float64 to be encoded and skips it if its value is 0.
326// Must be used inside an object as it will encode a key

Callers 2

AddFloat32KeyMethod · 0.95
MarshalJSONObjectMethod · 0.80

Calls 5

keyExistsMethod · 0.95
growMethod · 0.95
getPreviousRuneMethod · 0.95
writeByteMethod · 0.95
writeStringEscapeMethod · 0.95

Tested by 1

MarshalJSONObjectMethod · 0.64