package gojay// DecodeFloat64 reads the next JSON-encoded value from the decoder's input (io.Reader) and stores it in the float64 pointed to by v.//// See the documentation for Unmarshal for details about the conversion of JSON into a Go value.func ( *Decoder) ( *float64) error {if .isPooled == 1 {panic(InvalidUsagePooledDecoderError("Invalid usage of pooled decoder")) }return .decodeFloat64()}func ( *Decoder) ( *float64) error {for ; .cursor < .length || .read(); .cursor++ {switch := .data[.cursor]; {case' ', '\n', '\t', '\r', ',':continuecase'0', '1', '2', '3', '4', '5', '6', '7', '8', '9': , := .getFloat()if != nil {return } * = returnnilcase'-': .cursor = .cursor + 1 , := .getFloatNegative()if != nil {return } * = -returnnilcase'n': .cursor++ := .assertNull()if != nil {return }returnnildefault: .err = .makeInvalidUnmarshalErr() := .skipData()if != nil {return }returnnil } }return .raiseInvalidJSONErr(.cursor)}func ( *Decoder) ( **float64) error {for ; .cursor < .length || .read(); .cursor++ {switch := .data[.cursor]; {case' ', '\n', '\t', '\r', ',':continuecase'0', '1', '2', '3', '4', '5', '6', '7', '8', '9': , := .getFloat()if != nil {return }if * == nil { * = new(float64) } ** = returnnilcase'-': .cursor = .cursor + 1 , := .getFloatNegative()if != nil {return }if * == nil { * = new(float64) } ** = -returnnilcase'n': .cursor++ := .assertNull()if != nil {return }returnnildefault: .err = .makeInvalidUnmarshalErr() := .skipData()if != nil {return }returnnil } }return .raiseInvalidJSONErr(.cursor)}func ( *Decoder) () (float64, error) {// look for following numbersfor ; .cursor < .length || .read(); .cursor++ {switch .data[.cursor] {case'0', '1', '2', '3', '4', '5', '6', '7', '8', '9':return .getFloat()default:return0, .raiseInvalidJSONErr(.cursor) } }return0, .raiseInvalidJSONErr(.cursor)}func ( *Decoder) () (float64, error) {var = .cursorvar = .cursor// look for following numbersfor := .cursor + 1; < .length || .read(); ++ {switch .data[] {case'0', '1', '2', '3', '4', '5', '6', '7', '8', '9': = continuecase'.':// we get part before decimal as integer := .atoi64(, )// then we get part after decimal as integer = + 1// get number after the decimal pointfor := + 1; < .length || .read(); ++ { := .data[]ifisDigit() { = // multiply the before decimal point portion by 10 using bitwise // make sure it doesn't overflowif - < 18 { = ( << 3) + ( << 1) }continue } elseif ( == 'e' || == 'E') && < -1 {// we have an exponent, convert first the value we got before the exponentvarint64 := - + 2// if exp is too long, it means number is too long, just truncate the numberif >= len(pow10uint64) || < 0 { = len(pow10uint64) - 2 = .atoi64(, +-2) } else {// then we add both integers // then we divide the number by the power found = .atoi64(, ) } .cursor = + 1 := pow10uint64[] := float64(+) / float64() , := .getExponent()if != nil {return0, } := ( + ( >> 31)) ^ ( >> 31) + 1// absolute exponentif >= int64(len(pow10uint64)) || < 0 {return0, .raiseInvalidJSONErr(.cursor) }// if exponent is negativeif < 0 {returnfloat64() * (1 / float64(pow10uint64[])), nil }returnfloat64() * float64(pow10uint64[]), nil } .cursor = break }if >= .length || < {return0, .raiseInvalidJSONErr(.cursor) }varint64 := - + 2// if exp is too long, it means number is too long, just truncate the numberif >= len(pow10uint64) || < 0 { = 19 = .atoi64(, +-2) } else { = .atoi64(, ) } := pow10uint64[]// then we add both integers // then we divide the number by the power foundreturnfloat64(+) / float64(), nilcase'e', 'E': .cursor = + 1// we get part before decimal as integer := uint64(.atoi64(, ))// get exponent , := .getExponent()if != nil {return0, } := ( + ( >> 31)) ^ ( >> 31) + 1// absif >= int64(len(pow10uint64)) || < 0 {return0, .raiseInvalidJSONErr(.cursor) }// if exponent is negativeif < 0 {returnfloat64() * (1 / float64(pow10uint64[])), nil }returnfloat64() * float64(pow10uint64[]), nilcase' ', '\n', '\t', '\r', ',', '}', ']': // does not have decimal .cursor = returnfloat64(.atoi64(, )), nil }// invalid json we expect numbers, dot (single one), comma, or spacesreturn0, .raiseInvalidJSONErr(.cursor) }returnfloat64(.atoi64(, )), nil}// DecodeFloat32 reads the next JSON-encoded value from the decoder's input (io.Reader) and stores it in the float32 pointed to by v.//// See the documentation for Unmarshal for details about the conversion of JSON into a Go value.func ( *Decoder) ( *float32) error {if .isPooled == 1 {panic(InvalidUsagePooledDecoderError("Invalid usage of pooled decoder")) }return .decodeFloat32()}func ( *Decoder) ( *float32) error {for ; .cursor < .length || .read(); .cursor++ {switch := .data[.cursor]; {case' ', '\n', '\t', '\r', ',':continuecase'0', '1', '2', '3', '4', '5', '6', '7', '8', '9': , := .getFloat32()if != nil {return } * = returnnilcase'-': .cursor = .cursor + 1 , := .getFloat32Negative()if != nil {return } * = -returnnilcase'n': .cursor++ := .assertNull()if != nil {return }returnnildefault: .err = .makeInvalidUnmarshalErr() := .skipData()if != nil {return }returnnil } }return .raiseInvalidJSONErr(.cursor)}func ( *Decoder) ( **float32) error {for ; .cursor < .length || .read(); .cursor++ {switch := .data[.cursor]; {case' ', '\n', '\t', '\r', ',':continuecase'0', '1', '2', '3', '4', '5', '6', '7', '8', '9': , := .getFloat32()if != nil {return }if * == nil { * = new(float32) } ** = returnnilcase'-': .cursor = .cursor + 1 , := .getFloat32Negative()if != nil {return }if * == nil { * = new(float32) } ** = -returnnilcase'n': .cursor++ := .assertNull()if != nil {return }returnnildefault: .err = .makeInvalidUnmarshalErr() := .skipData()if != nil {return }returnnil } }return .raiseInvalidJSONErr(.cursor)}func ( *Decoder) () (float32, error) {// look for following numbersfor ; .cursor < .length || .read(); .cursor++ {switch .data[.cursor] {case'0', '1', '2', '3', '4', '5', '6', '7', '8', '9':return .getFloat32()default:return0, .raiseInvalidJSONErr(.cursor) } }return0, .raiseInvalidJSONErr(.cursor)}func ( *Decoder) () (float32, error) {var = .cursorvar = .cursor// look for following numbersfor := .cursor + 1; < .length || .read(); ++ {switch .data[] {case'0', '1', '2', '3', '4', '5', '6', '7', '8', '9': = continuecase'.':// we get part before decimal as integer := .atoi64(, )// then we get part after decimal as integer = + 1// get number after the decimal point // multiple the before decimal point portion by 10 using bitwisefor := + 1; < .length || .read(); ++ { := .data[]ifisDigit() { = // multiply the before decimal point portion by 10 using bitwise // make sure it desn't overflowif - < 9 { = ( << 3) + ( << 1) }continue } elseif ( == 'e' || == 'E') && < -1 {// we get the number before decimalvarint64 := - + 2// if exp is too long, it means number is too long, just truncate the numberif >= 12 || < 0 { = 10 = .atoi64(, +-2) } else { = .atoi64(, ) } .cursor = + 1 := pow10uint64[]// then we add both integers // then we divide the number by the power found := float32(+) / float32() , := .getExponent()if != nil {return0, } := ( + ( >> 31)) ^ ( >> 31) + 1// absif >= int64(len(pow10uint64)) || < 0 {return0, .raiseInvalidJSONErr(.cursor) }// if exponent is negativeif < 0 {returnfloat32() * (1 / float32(pow10uint64[])), nil }returnfloat32() * float32(pow10uint64[]), nil } .cursor = break }if >= .length || < {return0, .raiseInvalidJSONErr(.cursor) }// then we add both integers // then we divide the number by the power foundvarint64 := - + 2// if exp is too long, it means number is too long, just truncate the numberif >= 12 || < 0 { = 10 = .atoi64(, +-2) } else {// then we add both integers // then we divide the number by the power found = .atoi64(, ) } := pow10uint64[]returnfloat32(+) / float32(), nilcase'e', 'E': .cursor = + 1// we get part before decimal as integer := .atoi64(, )// get exponent , := .getExponent()if != nil {return0, } := ( + ( >> 31)) ^ ( >> 31) + 1if >= int64(len(pow10uint64)) || < 0 {return0, .raiseInvalidJSONErr(.cursor) }// if exponent is negativeif < 0 {returnfloat32() * (1 / float32(pow10uint64[])), nil }returnfloat32() * float32(pow10uint64[]), nilcase' ', '\n', '\t', '\r', ',', '}', ']': // does not have decimal .cursor = returnfloat32(.atoi64(, )), nil }// invalid json we expect numbers, dot (single one), comma, or spacesreturn0, .raiseInvalidJSONErr(.cursor) }returnfloat32(.atoi64(, )), nil}// Add Values functions// AddFloat decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( *float64) error {return .Float64()}// AddFloatNull decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.// If a `null` is encountered, gojay does not change the value of the pointer.func ( *Decoder) ( **float64) error {return .Float64Null()}// AddFloat64 decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( *float64) error {return .Float64()}// AddFloat64Null decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.// If a `null` is encountered, gojay does not change the value of the pointer.func ( *Decoder) ( **float64) error {return .Float64Null()}// AddFloat32 decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( *float32) error {return .Float32()}// AddFloat32Null decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.// If a `null` is encountered, gojay does not change the value of the pointer.func ( *Decoder) ( **float32) error {return .Float32Null()}// Float decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( *float64) error {return .Float64()}// FloatNull decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( **float64) error {return .Float64Null()}// Float64 decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( *float64) error { := .decodeFloat64()if != nil {return } .called |= 1returnnil}// Float64Null decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( **float64) error { := .decodeFloat64Null()if != nil {return } .called |= 1returnnil}// Float32 decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( *float32) error { := .decodeFloat32()if != nil {return } .called |= 1returnnil}// Float32Null decodes the JSON value within an object or an array to a *float64.// If next key value overflows float64, an InvalidUnmarshalError error will be returned.func ( *Decoder) ( **float32) error { := .decodeFloat32Null()if != nil {return } .called |= 1returnnil}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.