Overview
All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a specialJSON field containing metadata about each property.
Response Structure
Handling Optional Data
To handle optional data, use the.Valid() method on the JSON field.
.Valid() returns true if a field is not null, not present, or couldn’t be marshaled..Valid() is false, the corresponding field will simply be its zero value.
Complete Example
Extra Fields
These.JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct.
This can be useful for API features not yet present in the SDK.
Accessing Raw JSON
To access undocumented response properties, you may either:- Access the raw JSON of the response as a string with
result.JSON.RawJSON() - Get the raw JSON of a particular field on the result with
result.JSON.Foo.Raw()
result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.