codec

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: 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 codec 负责 App API 的 JSON、JWT、用户 ID 和响应数组解析。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaimString

func ClaimString(m map[string]any, keys ...string) string

ClaimString 返回 claims 中第一个非空字符串字段。

func DecodeSegment

func DecodeSegment(segment string) ([]byte, error)

DecodeSegment 解码不带 padding 的 base64url JWT segment。

func ObjectArray

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

ObjectArray 解码 JSON object 数组,保持 App API 原有的 nil/非法输入语义。

func ObjectSlice

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

ObjectSlice 将 App API 响应中的通用 slice 转成 object slice。

func ParseID

func ParseID(raw json.RawMessage) (int64, bool)

ParseID 从 JSON raw value 解析非零用户 ID;保留 API 对浮点数的截断行为。

func RawString

func RawString(m map[string]json.RawMessage, key string) string

RawString 读取 JSON object 中的字符串字段;非字符串值按原始 JSON 文本回退。

func UserIDFromJWT

func UserIDFromJWT(token string) (int64, string, bool)

UserIDFromJWT 从 JWT payload 解码常见用户 ID 和名称,不校验签名。

func UserIDFromMap

func UserIDFromMap(m map[string]json.RawMessage) (int64, string, bool)

UserIDFromMap 从 JSON object 的常见 id 字段解析非零用户 ID 和名称。

Types

This section is empty.

Jump to

Keyboard shortcuts

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