jsonany

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 6 Imported by: ? 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 jsonany 禁止 encoding/json.Unmarshal 直接解码到 any / map[string]any / []any。

Go 标准库 json.Unmarshal 把 JSON number 解进空接口时一律落成 float64, 会静默绕过 moneyfloat / decjson 对金额与业务数值的精度防护;同时丢失 结构契约校验。请解码到具名 DTO struct(金额字段为 string + money.ParseCanonical), 或使用 json.NewDecoder 配合 UseNumber()。

默认只查非生成生产代码(_test.go 与生成文件不查),-tests=true 连测试一起查。 确需动态 JSON 结构时,用 //appkit:ignore jsonany -- <理由> 显式豁免。

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "jsonany",
	Doc:  "禁止 json.Unmarshal 直接解码到 any / map[string]any / []any(JSON number 会静默转成 float64);请改用具名 DTO struct 或 json.Decoder.UseNumber",
	Run:  run,
}

Analyzer 是 jsonany 检查器。

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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