Documentation
¶
Overview ¶
Package ron converts between RON, Readable Object Notation, and JSON.
Index ¶
- Constants
- func FromJSON(src []byte, options ...Option) ([]byte, error)
- func FromJSONCompact(src []byte) ([]byte, error)
- func FromJSONCompactInto(dst *bytes.Buffer, src []byte) ([]byte, error)
- func FromJSONInto(dst *bytes.Buffer, src []byte, options ...Option) ([]byte, error)
- func MarshalCompact(value any) ([]byte, error)
- func Tagged(tag string, value any) map[string]any
- func ToJSON(src []byte, options ...Option) ([]byte, error)
- func ToJSONInto(dst *bytes.Buffer, src []byte, options ...Option) ([]byte, error)
- func ValidateVocabularyProfile(src []byte, options ...Option) error
- type Box2
- type Box3
- type Bytes
- type CIDR
- type Color
- type ColorSpace
- type CustomParseFunc
- type CustomRenderFunc
- type CustomValue
- type CustomVocabulary
- type Cylindrical
- type Decimal
- type Duration
- type EntityRef
- type Euler
- type EulerOrder
- type Float64
- type Frustum
- type GeoJSON
- type IPv4
- type IPv6
- type Instant
- type Int64
- type IntVector2
- type IntVector3
- type IntVector4
- type IntVectorN
- type JSONPathSegment
- type Line2
- type Line3
- type LngLatAlt
- type Matrix2
- type Matrix3
- type Matrix4
- type OpaqueTag
- type Option
- func EnableVocabularies(uris ...string) Option
- func Indent(indent string) Option
- func IsCanonical(canonical bool) Option
- func IsPretty(pretty bool) Option
- func MapJSONValues(mapper func(path []JSONPathSegment, value any) (any, bool)) Option
- func PrettyJSON(prefix, indent string) Option
- func UseCustomVocabulary(vocabulary CustomVocabulary) Option
- type Plane
- type Quaternion
- type Ray
- type SHA256
- type Sphere
- type Spherical
- type SphericalHarmonics3
- type Triangle
- type UUID
- type Uint64
- type Vector2
- type Vector3
- type Vector4
- type VectorN
- type VocabularyProfile
- type VoxelCell
- type VoxelSet
Constants ¶
const ( EulerOrderXYZ = ronmath.EULER_ORDER_XYZ EulerOrderYXZ = ronmath.EULER_ORDER_YXZ EulerOrderZXY = ronmath.EULER_ORDER_ZXY EulerOrderZYX = ronmath.EULER_ORDER_ZYX EulerOrderYZX = ronmath.EULER_ORDER_YZX EulerOrderXZY = ronmath.EULER_ORDER_XZY )
const (
// VocabularyColorV1 is the RON color typed vocabulary URI.
VocabularyColorV1 = "https://ron.dev/vocab/color/v1"
)
const (
// VocabularyCoreV1 is the RON core typed vocabulary URI.
VocabularyCoreV1 = "https://ron.dev/vocab/core/v1"
)
const (
// VocabularyGeoV1 is the RON GeoJSON typed vocabulary URI.
VocabularyGeoV1 = "https://ron.dev/vocab/geo/v1"
)
const (
// VocabularyMathV1 is the RON math typed vocabulary URI.
VocabularyMathV1 = "https://ron.dev/vocab/math/v1"
)
const (
// VocabularyNetworkV1 is the RON network typed vocabulary URI.
VocabularyNetworkV1 = "https://ron.dev/vocab/network/v1"
)
const (
// VocabularySpatialV1 is the RON spatial typed vocabulary URI.
VocabularySpatialV1 = "https://ron.dev/vocab/spatial/v1"
)
const (
// VocabularyTimeV1 is the RON time typed vocabulary URI.
VocabularyTimeV1 = "https://ron.dev/vocab/time/v1"
)
Variables ¶
This section is empty.
Functions ¶
func FromJSONCompact ¶
FromJSONCompact converts JSON to compact RON.
func FromJSONCompactInto ¶
FromJSONCompactInto appends JSON converted to compact RON to dst.
func FromJSONInto ¶
FromJSONInto appends JSON converted to RON to dst.
func MarshalCompact ¶
MarshalCompact returns value as compact RON.
func Tagged ¶ added in v0.0.2
Tagged returns a single-member object that renders as a tagged RON form. An empty tag renders as #. Payload validation is left to application-specific typed hooks.
func ToJSONInto ¶
ToJSONInto appends RON converted to JSON to dst.
func ValidateVocabularyProfile ¶ added in v0.0.3
ValidateVocabularyProfile rejects required vocabularies that ron-go does not support.
Types ¶
type Bytes ¶ added in v0.0.3
type Bytes []byte
Bytes is a core vocabulary #b64 value decoded from base64url without padding.
type Color ¶ added in v0.0.3
type Color struct {
Space ColorSpace
Channels []float64
Value colorlib.Color
}
Color is a color vocabulary #clr value.
func NewOKLCHColor ¶ added in v0.0.3
type ColorSpace ¶ added in v0.0.3
type ColorSpace string
ColorSpace names a color vocabulary color space.
const ( ColorSpaceRGB ColorSpace = "rgb" ColorSpaceRGBA ColorSpace = "rgba" ColorSpaceHSL ColorSpace = "hsl" ColorSpaceHSLA ColorSpace = "hsla" ColorSpaceHSV ColorSpace = "hsv" ColorSpaceHSVA ColorSpace = "hsva" ColorSpaceHWB ColorSpace = "hwb" ColorSpaceHWBA ColorSpace = "hwba" ColorSpaceLAB ColorSpace = "lab" ColorSpaceLABA ColorSpace = "laba" ColorSpaceLCH ColorSpace = "lch" ColorSpaceLCHA ColorSpace = "lcha" ColorSpaceOKLAB ColorSpace = "oklab" ColorSpaceOKLABA ColorSpace = "oklaba" // ColorSpaceOKLCH is the canonical color vocabulary color space. ColorSpaceOKLCH ColorSpace = "oklch" ColorSpaceOKLCHA ColorSpace = "oklcha" ColorSpaceXYZ ColorSpace = "xyz" ColorSpaceXYZA ColorSpace = "xyza" )
type CustomParseFunc ¶ added in v0.0.3
CustomParseFunc validates and maps a custom typed payload.
type CustomRenderFunc ¶ added in v0.0.3
CustomRenderFunc maps a native value to a custom typed tag and payload.
type CustomValue ¶ added in v0.0.3
CustomValue is a generic custom typed value.
func Custom ¶ added in v0.0.3
func Custom(tag string, payload any) CustomValue
Custom returns a generic custom typed value.
type CustomVocabulary ¶ added in v0.0.3
type CustomVocabulary struct {
URI string
Tags []string
Parse CustomParseFunc
Render CustomRenderFunc
}
CustomVocabulary defines an option-scoped typed vocabulary.
type Cylindrical ¶ added in v0.0.3
type Cylindrical = ronmath.Cylindrical[float64]
Cylindrical is a spatial vocabulary #cyl value.
type EntityRef ¶ added in v0.0.3
type EntityRef struct {
Value any
}
EntityRef is a core vocabulary # value for integer or string entity references.
type EulerOrder ¶ added in v0.0.3
type EulerOrder = ronmath.EulerOrder
EulerOrder is the rotation order for a math vocabulary #eul value.
type IntVector2 ¶ added in v0.0.3
type IntVector2 [2]int64
IntVector2 is a math vocabulary #iv2 value.
type IntVector3 ¶ added in v0.0.3
type IntVector3 [3]int64
IntVector3 is a math vocabulary #iv3 value.
type IntVector4 ¶ added in v0.0.3
type IntVector4 [4]int64
IntVector4 is a math vocabulary #iv4 value.
type IntVectorN ¶ added in v0.0.3
type IntVectorN []int64
IntVectorN is a math vocabulary #ivN value.
type JSONPathSegment ¶ added in v0.0.2
JSONPathSegment identifies one object key or array index in a decoded JSON value.
type Line2 ¶ added in v0.0.3
type Line2 struct {
Line orb.LineString
}
Line2 is a spatial vocabulary #ln2 value.
type OpaqueTag ¶ added in v0.0.3
OpaqueTag is a core vocabulary #tag value with implementation-defined payload.
type Option ¶
type Option func(*optionState)
Option configures RON and JSON conversion.
func EnableVocabularies ¶ added in v0.0.3
EnableVocabularies enables validation for supported typed vocabulary URIs. Supported vocabularies are enabled by default; use this for explicit profiles. Unsupported typed values remain ordinary JSON/RON objects unless their vocabulary is enabled.
func IsCanonical ¶
IsCanonical selects RFC 8785 UTF-16 object key ordering when true. When false, source object order is preserved when available; unordered Go maps use canonical order.
func MapJSONValues ¶ added in v0.0.2
func MapJSONValues(mapper func(path []JSONPathSegment, value any) (any, bool)) Option
MapJSONValues transforms decoded JSON values before JSON-to-RON rendering.
func PrettyJSON ¶
PrettyJSON enables indented JSON output.
func UseCustomVocabulary ¶ added in v0.0.3
func UseCustomVocabulary(vocabulary CustomVocabulary) Option
UseCustomVocabulary enables an option-scoped custom vocabulary.
type Quaternion ¶ added in v0.0.3
type Quaternion = ronmath.Quaternion[float64]
Quaternion is a math vocabulary #qat value.
type SphericalHarmonics3 ¶ added in v0.0.3
type SphericalHarmonics3 = ronmath.SphericalHarmonics3[float64]
SphericalHarmonics3 is a spatial vocabulary #sh3 value.
type VocabularyProfile ¶ added in v0.0.3
VocabularyProfile declares required and optional typed vocabularies.