We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot unmarshal null fields to UUID, even though I already uses ConfigCompatibleWithStandardLibrary which ensures 100% compatibility.
ConfigCompatibleWithStandardLibrary
It also fails with the NewDecoder.Decode function.
Sample Program:
package main import ( "bytes" "fmt" "encoding/json" "github.com/google/uuid" jsoniterlib "github.com/json-iterator/go" ) type TestStruct struct { SomeUUID uuid.UUID `json:"someUUID"` NilUUID uuid.UUID `json:"nilUUID"` } var jsoniter = jsoniterlib.ConfigCompatibleWithStandardLibrary func main() { fmt.Println("jsoniter fails to decode null field to UUID") var err error var test TestStruct err = jsoniter.Unmarshal(bytes.NewBufferString(`{"someUUID":"fa0e715a-7234-4110-aed0-ecc3de305e62","nilUUID":null}`).Bytes(), &test) fmt.Println(test) fmt.Println(err) fmt.Println("\nexpected results:") var err2 error var test2 TestStruct err2 = json.Unmarshal(bytes.NewBufferString(`{"someUUID":"fa0e715a-7234-4110-aed0-ecc3de305e62","nilUUID":null}`).Bytes(), &test2) fmt.Println(test2) fmt.Println(err2) }
Results:
jsoniter fails to decode null field to UUID {fa0e715a-7234-4110-aed0-ecc3de305e62 00000000-0000-0000-0000-000000000000} main.TestStruct.NilUUID: textUnmarshalerDecoder: invalid UUID length: 0, error found in #10 byte of ...|UUID":null}|..., bigger context ...|0e715a-7234-4110-aed0-ecc3de305e62","nilUUID":null}|... expected results: {fa0e715a-7234-4110-aed0-ecc3de305e62 00000000-0000-0000-0000-000000000000} <nil>
Ran on golang 1.21.0
The text was updated successfully, but these errors were encountered:
@farisekananda I made some checks in my local einvironment (go 1.20.14) with the latest version available for this pkg and no errors have been raised
Sorry, something went wrong.
No branches or pull requests
Cannot unmarshal null fields to UUID, even though I already uses
ConfigCompatibleWithStandardLibrary
which ensures 100% compatibility.It also fails with the NewDecoder.Decode function.
Sample Program:
Results:
Ran on golang 1.21.0
The text was updated successfully, but these errors were encountered: