diff --git a/internal/apijson/field.go b/internal/apijson/field.go index 854d6dd7..53349a7c 100644 --- a/internal/apijson/field.go +++ b/internal/apijson/field.go @@ -14,7 +14,7 @@ type Field struct { status status } -// Returns true if the field is explicitly `null` _or_ if it is not present at all (ie, missing). +// IsNull returns true if the field is explicitly `null` _or_ if it is not present at all (ie, missing). // To check if the field's key is present in the JSON with an explicit null value, // you must check `f.IsNull() && !f.IsMissing()`. func (j Field) IsNull() bool { return j.status <= null } diff --git a/internal/apijson/subfield.go b/internal/apijson/subfield.go index 6f9e2bdb..2ee3845d 100644 --- a/internal/apijson/subfield.go +++ b/internal/apijson/subfield.go @@ -1,8 +1,9 @@ package apijson import ( - "github.com/openai/openai-go/packages/resp" "reflect" + + "github.com/openai/openai-go/packages/resp" ) func getSubField(root reflect.Value, index []int, name string) reflect.Value { @@ -55,10 +56,10 @@ func setMetadataExtraFields(root reflect.Value, index []int, name string, metaEx } func (f Field) toRespField() resp.Field { - if f.IsNull() { - return resp.NewNullField() - } else if f.IsMissing() { + if f.IsMissing() { return resp.Field{} + } else if f.IsNull() { + return resp.NewNullField() } else if f.IsInvalid() { return resp.NewInvalidField(f.raw) } else {