jsonnum

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package jsonnum converts json.Number values into concrete Go numbers.

Integral numbers that fit in 64 bits become int64, however they are written (3, 3.0, 3e0); all others become float64. JSON Schema counts 3.0 as an integer, so storing it as int64 keeps "integer" fields integer-typed in MongoDB. Integers beyond 64 bits stay float64 (and may lose precision).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(v any) any

Normalize returns v with every json.Number (at any depth inside maps and slices) replaced by an int64 or float64. Maps and slices are modified in place.

func Number

func Number(n json.Number) any

Number converts one json.Number. Integral values outside the int64 range, and values with a fraction or exponent, become float64.

Types

This section is empty.

Jump to

Keyboard shortcuts

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