replicate / replicate-go

Go client for Replicate
https://replicate.com
Apache License 2.0
65 stars 9 forks source link

Store and retrieve raw JSON response from server #19

Closed mattt closed 1 year ago

mattt commented 1 year ago

For the CLI, it'd be helpful to print the original JSON sent from the server. Currently, the Go objects are decoded from the server JSON and re-encoded into JSON, which would omit any fields that aren't accounted for in the model.

This PR adds an internal rawJSON field to structs, which stores the raw JSON message passed in UnmarshalJSON. If rawJSON isn't blank, MarshalJSON returns this value directly; otherwise, the object is marshaled normally.