jsonx

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 2 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 提供纯 JSON 编解码 helper。

该包只做字节级转换,不接收 io.Writer、不写输出、不含 CLI 文案、不吞掉编码错误; CLI/SDK/App API 的 JSON 字节契约统一由此保证。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalLine

func MarshalLine(value any) ([]byte, error)

MarshalLine 以紧凑 JSON 编码 value,SetEscapeHTML(false), 成功时返回恰好包含一个尾随换行的字节。编码失败原样返回错误。

func ObjectArray

func ObjectArray(raw json.RawMessage) []map[string]any

ObjectArray 解码 JSON object 数组;空值、null、非法 JSON 或非数组返回 nil。 数组中的 null 元素按 encoding/json 的既有语义保留为 nil map。

func ObjectSlice

func ObjectSlice(v any) []map[string]any

ObjectSlice 将常见的 map slice 或可 JSON 编码的 slice 转换为 object slice。 []any 中的非 map 元素沿用 App API 原有实现,直接忽略。

func RawString

func RawString(raw json.RawMessage) string

RawString 读取 JSON 原始标量字符串字段:若原始值以引号包裹则剥除外层引号, 否则返回原始文本。不擅自 unescape 或规范化内容。

Types

This section is empty.

Jump to

Keyboard shortcuts

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