jsonextractor

package
v1.4.3-beta3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: AGPL-3.0 Imports: 14 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractJSONWithRaw

func ExtractJSONWithRaw(raw string) (results []string, rawStr []string)

func ExtractObjectIndexes

func ExtractObjectIndexes(c string) [][2]int

func ExtractObjectsOnly

func ExtractObjectsOnly(raw string) []string

ExtractObjectsOnly 从输入中提取所有对象, 为了保持兼容性 不管输入是对象、数组还是混合文本,最终只返回对象

func ExtractStandardJSON

func ExtractStandardJSON(raw string) []string

ExtractJSON 尝试提取字符串中的 JSON 并进行修复, 返回中的元素都是原始 Json Example: ``` json.ExtractJson("hello yak") // [] res = json.ExtractJson(`[{"hello": "yak"}]`) // [[{"key": "value"}]] assert(res[0]==`[{"key": "value"}]`) ```

func ExtractStructuredJSON

func ExtractStructuredJSON(c string, options ...CallbackOption) error

func ExtractStructuredJSONFromStream

func ExtractStructuredJSONFromStream(jsonReader io.Reader, options ...CallbackOption) error

func FixJson

func FixJson(b []byte) []byte

func JsonValidObject

func JsonValidObject(b []byte) ([]byte, bool)

Types

type CallbackOption

type CallbackOption func(*callbackManager)

func WithArrayCallback

func WithArrayCallback(callback func(data []any)) CallbackOption

func WithObjectCallback

func WithObjectCallback(callback func(data map[string]any)) CallbackOption

func WithObjectKeyValue

func WithObjectKeyValue(callback func(string string, data any)) CallbackOption

func WithRawKeyValueCallback

func WithRawKeyValueCallback(callback func(key, data any)) CallbackOption

func WithRootMapCallback

func WithRootMapCallback(callback func(data map[string]any)) CallbackOption

type RAW_VALUE_TYPE

type RAW_VALUE_TYPE int
const (
	RAW_VALUE_TYPE_RAW RAW_VALUE_TYPE = 0
	RAW_VALUE_TYPE_ARR RAW_VALUE_TYPE = 1
	RAW_VALUE_TYPE_MAP RAW_VALUE_TYPE = 2
)

Jump to

Keyboard shortcuts

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