jt

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package jt defines the Size type to handle size parameters in JSON structures in a more user-friendly way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Size

type Size int

Size is a specific type for handling data size parameters. It shortens the string representation. For instance 8 MiB are represented as "8M", 16 KiB as "16K", 2 GiB as "2G". It is also possible to use plain numbers for it.

func (Size) MarshalJSON

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

MarshalJSON returns the string representation of the size as byte slice. It is used by the JSON encoder.

func (Size) String

func (s Size) String() string

String returns the string representation of the size. It uses K, M, and G as suffixes for KiB, MiB, and GiB, respectively.

func (*Size) UnmarshalJSON

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

UnmarshalText parses the string representation of the size and sets the value of s. It is used by the JSON decoder.

Jump to

Keyboard shortcuts

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