Accept equivalent integer references in model responses
This commit is contained in:
@@ -143,17 +143,7 @@ func extractSegments(raw []byte) (json.RawMessage, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// sourceID decodes native integers without routing them through float64.
|
||||
// Decimal and exponent spellings are accepted if they denote an exact integer.
|
||||
type sourceID int
|
||||
|
||||
func (id *sourceID) UnmarshalJSON(raw []byte) error {
|
||||
if value, ok := jsonnumber.Int(string(raw)); ok {
|
||||
*id = sourceID(value)
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(raw, (*int)(id))
|
||||
}
|
||||
type sourceID = jsonnumber.Integer
|
||||
|
||||
func validateSourceSegments(segments []SourceSegment) error {
|
||||
for i, s := range segments {
|
||||
|
||||
Reference in New Issue
Block a user