Documentation
¶
Overview ¶
Package shared contains shared JSON scalar helpers used by Polymarket API packages.
Custom Types ¶
Polymarket returns numeric values as both JSON numbers and decimal strings (e.g. "0.50" vs 0.50). These types handle the ambiguity:
- String — preserves a stable string form for strings, numbers, and booleans
- Int, Int64, Uint64, and Float64 — accept quoted or native JSON numbers
- Time and Date — accept common Polymarket timestamp and date encodings
- StringSlice and Float64Slice — accept arrays and string-encoded arrays
Usage ¶
type Market struct {
ID shared.String `json:"id"`
Volume shared.Float64 `json:"volume"`
EndDate shared.Time `json:"endDate"`
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Date ¶
Date accepts a JSON date string in YYYY-MM-DD format.
func (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
type Float64 ¶
type Float64 float64
Float64 accepts either a JSON number or a quoted floating-point number.
func (Float64) MarshalJSON ¶
func (*Float64) UnmarshalJSON ¶
type Float64Slice ¶
type Float64Slice []Float64
Float64Slice accepts JSON number arrays and JSON-encoded string arrays.
func (Float64Slice) MarshalJSON ¶
func (s Float64Slice) MarshalJSON() ([]byte, error)
func (*Float64Slice) UnmarshalJSON ¶
func (s *Float64Slice) UnmarshalJSON(data []byte) error
type Int ¶
type Int int
Int accepts either a JSON number or a quoted base-10 integer.
func (Int) MarshalJSON ¶
func (*Int) UnmarshalJSON ¶
type Int64 ¶
type Int64 int64
Int64 accepts either a JSON number or a quoted base-10 integer.
func (Int64) MarshalJSON ¶
func (*Int64) UnmarshalJSON ¶
type Page ¶ added in v1.1.1
type Page[T any] struct { // Limit is the requested page size. Limit Int `json:"limit"` // Count is the number of results on this page. Count Int `json:"count"` // NextCursor is the pagination cursor for the next page, empty when exhausted. NextCursor string `json:"next_cursor"` // Data contains the page results. Data []T `json:"data"` }
Page wraps a paginated API response.
type String ¶
type String string
String accepts JSON strings, numbers, and booleans while preserving a stable string form.
func (String) MarshalJSON ¶
func (*String) UnmarshalJSON ¶
type StringSlice ¶
type StringSlice []string
StringSlice accepts JSON arrays, JSON-encoded string arrays, and comma-separated strings.
func (StringSlice) MarshalJSON ¶
func (s StringSlice) MarshalJSON() ([]byte, error)
func (*StringSlice) UnmarshalJSON ¶
func (s *StringSlice) UnmarshalJSON(data []byte) error
type Time ¶
Time accepts RFC3339 strings, date-only strings, Unix seconds, Unix milliseconds, and numeric strings.