shared

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

func ParseTime

func ParseTime(value string) (time.Time, error)

ParseTime parses RFC3339, date-only, Unix seconds, or Unix milliseconds values.

Types

type Date

type Date time.Time

Date accepts a JSON date string in YYYY-MM-DD format.

func (Date) IsZero

func (d Date) IsZero() bool

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (Date) Time

func (d Date) Time() time.Time

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

type Float64

type Float64 float64

Float64 accepts either a JSON number or a quoted floating-point number.

func (Float64) MarshalJSON

func (n Float64) MarshalJSON() ([]byte, error)

func (*Float64) UnmarshalJSON

func (n *Float64) UnmarshalJSON(data []byte) error

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 (n Int) MarshalJSON() ([]byte, error)

func (*Int) UnmarshalJSON

func (n *Int) UnmarshalJSON(data []byte) error

type Int64

type Int64 int64

Int64 accepts either a JSON number or a quoted base-10 integer.

func (Int64) MarshalJSON

func (n Int64) MarshalJSON() ([]byte, error)

func (*Int64) UnmarshalJSON

func (n *Int64) UnmarshalJSON(data []byte) error

type String

type String string

String accepts JSON strings, numbers, and booleans while preserving a stable string form.

func (String) MarshalJSON

func (s String) MarshalJSON() ([]byte, error)

func (String) String

func (s String) String() string

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(data []byte) error

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

type Time time.Time

Time accepts RFC3339 strings, date-only strings, Unix seconds, Unix milliseconds, and numeric strings.

func (Time) IsZero

func (t Time) IsZero() bool

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) Time

func (t Time) Time() time.Time

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

type Uint64

type Uint64 uint64

Uint64 accepts either a JSON number or a quoted base-10 unsigned integer.

func (Uint64) MarshalJSON

func (n Uint64) MarshalJSON() ([]byte, error)

func (*Uint64) UnmarshalJSON

func (n *Uint64) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL