Versions in this module Expand all Collapse all v0 v0.1.1 Jul 22, 2026 v0.1.0 Jul 22, 2026 Changes in this version + const ClassBundle + const ClassCollection + const ClassDataset + const ClassDimension + const FormatVersion + const PositionEnd + const PositionStart + var ErrBuildIncomplete = errors.New("jsonstat: incomplete cube definition") + var ErrCategoryNotFound = errors.New("jsonstat: category not found") + var ErrCellMissing = errors.New("jsonstat: cell has no value") + var ErrCoordLenMismatch = errors.New("jsonstat: coordinate length mismatch") + var ErrDatasetNotFound = errors.New("jsonstat: dataset not found") + var ErrDimensionNotFound = errors.New("jsonstat: dimension not found") + var ErrEmptyDocument = errors.New("jsonstat: empty document") + var ErrHTTPFailure = errors.New("jsonstat: HTTP request failed") + var ErrIndexOutOfRange = errors.New("jsonstat: index out of range") + var ErrInvalidSize = errors.New("jsonstat: invalid size") + var ErrItemNotFound = errors.New("jsonstat: item not found") + var ErrMissingRequired = errors.New("jsonstat: missing required property") + var ErrResponseTooLarge = errors.New("jsonstat: response too large") + var ErrSparseValueLength = errors.New("jsonstat: sparse value key out of range") + var ErrStatusShape = errors.New("jsonstat: invalid status shape") + var ErrUnknownClass = errors.New("jsonstat: unknown response class") + var ErrUnsupportedVersion = errors.New("jsonstat: unsupported version") + var ErrValueShape = errors.New("jsonstat: invalid value shape") + var Version = "0.1.0" + func CoordinatesCategoryKey(prefix string, catIndex int) string + func Encode(w *bytes.Buffer, doc *Document) error + func EncodeBytes(doc *Document) ([]byte, error) + func FormatValidationReport(errs []ValidationError) string + func MarshalCollection(c *Collection) ([]byte, error) + func MarshalDataset(ds *Dataset) ([]byte, error) + func MarshalDimension(dim *Dimension) ([]byte, error) + func MarshalDocument(doc *Document) ([]byte, error) + func VersionInfo() map[string]string + type Builder struct + func NewBuilder() *Builder + func (b *Builder) Build() (*Dataset, error) + func (b *Builder) DenseValuesWithMissing(vals []float64, missing []bool) *Builder + func (b *Builder) Dim(id, label string) *DimBuilder + func (b *Builder) Extension(key string, value any) *Builder + func (b *Builder) Href(s string) *Builder + func (b *Builder) Label(s string) *Builder + func (b *Builder) Note(s string) *Builder + func (b *Builder) Source(s string) *Builder + func (b *Builder) SparseValues(m map[int]float64) *Builder + func (b *Builder) StatusArray(arr []string) *Builder + func (b *Builder) StatusMap(m map[int]string) *Builder + func (b *Builder) UniformStatus(s string) *Builder + func (b *Builder) Updated(s string) *Builder + func (b *Builder) Values(vals []float64) *Builder + type Category struct + Coordinates []float64 + ID string + Index int + Label string + Unit *Unit + type Cell struct + Coords []int + Flat int + Missing bool + Status string + Value float64 + func (c Cell) HasValue() bool + type Collection struct + Extension map[string]any + Href string + Items []Item + Label string + Link []Link + Note []string + Source string + Updated string + func (c *Collection) Datasets() []*Dataset + func (c *Collection) ItemByID(id string) (*Item, error) + func (c *Collection) ItemByIndex(i int) (*Item, error) + func (c *Collection) ItemsByClass(class string) []*Item + func (c *Collection) MarshalJSON() ([]byte, error) + type Content string + const ContentID + const ContentLabel + type Coordinates map[string]string + type DataTable struct + Cols []DataTableCol + Rows []DataTableRow + type DataTableCol struct + ID string + Label string + Type string + type DataTableRow struct + C map[string]any + type Datapoint struct + Missing bool + Status string + Value float64 + type Dataset struct + Class string + Dimensions map[string]*Dimension + Extension map[string]any + Href string + ID []string + Label string + Link []Link + Note []string + Role map[Role][]string + Size []int + Source string + Updated string + Version string + func (d *Dataset) CellByCoord(coords ...int) (Cell, error) + func (d *Dataset) CellByFlat(i int) (Cell, error) + func (d *Dataset) CellByLabel(m map[string]string) (Cell, error) + func (d *Dataset) Cells() iter.Seq2[Cell, error] + func (d *Dataset) CellsSlice() ([]Cell, error) + func (d *Dataset) Dice(f Filter, opts ...DiceOption) (*Dataset, error) + func (d *Dataset) DimCount() int + func (d *Dataset) Dimension(id string) (*Dimension, error) + func (d *Dataset) DimensionByIndex(i int) (*Dimension, error) + func (d *Dataset) DimensionByRole(role Role) (*Dimension, error) + func (d *Dataset) DimensionIDs() []string + func (d *Dataset) DimensionPosition(id string) (int, error) + func (d *Dataset) DimensionsByRole(role Role) []*Dimension + func (d *Dataset) HasRole(role Role) bool + func (d *Dataset) MarshalJSON() ([]byte, error) + func (d *Dataset) N() int + func (d *Dataset) Roles() []Role + func (d *Dataset) SizeSlice() []int + func (d *Dataset) StatusFormat() string + func (d *Dataset) Strides() []int + func (d *Dataset) Transform(opts ...TransformOption) (any, error) + func (d *Dataset) Unflatten(fn UnflattenFunc) ([]any, error) + func (d *Dataset) ValueFormat() string + func (d *Dataset) Walk(fn func(Cell) error) error + type DiceOption func(*diceConfig) + func WithClone(b bool) DiceOption + func WithDropFilter(b bool) DiceOption + type DimBuilder struct + func (d *DimBuilder) Cat(id, label string) *DimBuilder + func (d *DimBuilder) CatWith(c catSpec) *DimBuilder + func (d *DimBuilder) Coordinates(lon, lat float64) *DimBuilder + func (d *DimBuilder) End() *Builder + func (d *DimBuilder) Role(r Role) *DimBuilder + func (d *DimBuilder) Unit(u *Unit) *DimBuilder + type Dimension struct + Categories []Category + Child map[string][]string + Extension map[string]any + Href string + ID string + Label string + Link []Link + Note []string + Role Role + Size int + func (d *Dimension) CategoryByID(id string) (*Category, error) + func (d *Dimension) CategoryIDs() []string + func (d *Dimension) CategoryIndex(id string) (int, error) + func (d *Dimension) CategoryLabels() []string + func (d *Dimension) ChildrenOf(parentID string) ([]string, bool) + func (d *Dimension) HasHierarchy() bool + func (d *Dimension) MarshalJSON() ([]byte, error) + type Document struct + Bundle map[string]*Dataset + Class string + Collection *Collection + Dataset *Dataset + Dimension *Dimension + Extension map[string]any + Href string + IsBundle bool + Label string + Link []Link + Note []string + Version string + func Decode(r io.Reader) (*Document, error) + func DecodeBytes(b []byte) (*Document, error) + func Fetch(ctx context.Context, url string, opts ...FetchOption) (*Document, error) + func (d *Document) Datasets() []*Dataset + func (d *Document) IsCollection() bool + func (d *Document) IsDataset() bool + func (d *Document) IsDimension() bool + func (d *Document) SingleDataset() (*Dataset, error) + func (doc *Document) MarshalJSON() ([]byte, error) + type FetchOption func(*fetchConfig) + func WithBody(r io.Reader) FetchOption + func WithHTTPClient(c *http.Client) FetchOption + func WithHeader(key, value string) FetchOption + func WithMaxBytes(n int64) FetchOption + func WithMethod(m string) FetchOption + func WithUserAgent(ua string) FetchOption + type Field string + const FieldID + const FieldLabel + type Filter map[string][]string + type Item struct + Class string + EmbeddedDataset *Dataset + EmbeddedDimension *Dimension + Extension map[string]any + Href string + ID string + Label string + Type string + func (i *Item) IsEmbedded() bool + type Link struct + Extension map[string]any + Href string + Label string + Rel string + Type string + type Role string + const RoleGeo + const RoleMetric + const RoleTime + type TableDimCategories struct + ID []string + Label []string + type TableDimMeta struct + Categories TableDimCategories + Label string + Role string + type TableMeta struct + By string + Comma bool + Dimensions map[string]TableDimMeta + Drop []string + ID []string + Label string + Prefix string + Source string + Status bool + Type string + Updated string + type TableWithMeta struct + Data any + Meta TableMeta + type TransformOption func(*transformConfig) + func WithBy(dimID string) TransformOption + func WithComma(b bool) TransformOption + func WithContent(ct Content) TransformOption + func WithDrop(dimIDs ...string) TransformOption + func WithField(f Field) TransformOption + func WithMeta(b bool) TransformOption + func WithPrefix(s string) TransformOption + func WithStatus(b bool) TransformOption + func WithStatusLabel(s string) TransformOption + func WithTransformType(t TransformType) TransformOption + func WithValueLabel(s string) TransformOption + type TransformType string + const TransformArrObj + const TransformArray + const TransformObjArr + const TransformObject + type UnflattenFunc func(coords Coordinates, dp Datapoint, n int, row []any) any + type Unit struct + Decimals int + Label string + Position string + Symbol string + type ValidationCode string + const CodeCategorySizeMismatch + const CodeDimExtra + const CodeDimMissing + const CodeDuplicateCategoryID + const CodeDuplicateDimID + const CodeIDSizeMismatch + const CodeInvalidSize + const CodeMissingClass + const CodeMissingRequired + const CodeRoleReferencesUnknownDim + const CodeSparseValueKeyOutOfRange + const CodeStatusLengthMismatch + const CodeUnknownClass + const CodeValueLengthMismatch + type ValidationError struct + Code ValidationCode + Err error + Message string + Path string + func Validate(doc *Document) []ValidationError + func ValidateDataset(ds *Dataset, prefix string) []ValidationError + func (v *ValidationError) Error() string + func (v *ValidationError) HasSeverity() string + func (v *ValidationError) Unwrap() error + type ValueError struct + Cat string + Dim string + Err error + Flat int + Op string + func (v *ValueError) Error() string + func (v *ValueError) Unwrap() error