jsonx

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsonx reads JSON as the reference SDK's JSON.parse does, into values a caller reads by exact member name: objects as map[string]any, arrays as []any, strings, booleans, nil, and numbers kept as their text (json.Number), so a whole number written 4.0, a number past 2^53 and one past a double's range are each seen for what they are.

encoding/json decoding into a struct matches member names without regard to case; nothing here does that.

Index

Constants

View Source
const MaxSafeInteger = 1<<53 - 1

MaxSafeInteger is Number.MAX_SAFE_INTEGER, 2^53 - 1.

Variables

This section is empty.

Functions

func Bool

func Bool(v any) (bool, bool)

Bool is v as a JSON boolean.

func IsInteger

func IsInteger(f float64) bool

IsInteger is Number.isInteger.

func IsTrue

func IsTrue(v any) bool

IsTrue is v === true.

func Number

func Number(v any) (float64, bool)

Number is v as a JavaScript number when it is a JSON number: the double nearest its text, correctly rounded, +Inf or -Inf past a double's range and a signed zero below it, as JSON.parse reads one.

func Object

func Object(v any) (map[string]any, bool)

Object is v as a JSON object: not null, not an array.

func Parse

func Parse(data []byte) (any, error)

Parse is JSON.parse of data: one JSON value, with nothing after it but JSON white space. Duplicate members keep the last, as JSON.parse does.

Two differences from JSON.parse, both out of reach of anything the server signs: a lone surrogate escape ("\ud800") reads as U+FFFD, which JavaScript keeps as it is (the signer refuses such text, sdk-contract.md 2.1); and nesting deeper than encoding/json's 10,000 levels is refused.

func String

func String(v any) (string, bool)

String is v as a JSON string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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