utils

package
v0.13.20 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Example

func Example()

Example 使用示例

Types

type SerializeHelper

type SerializeHelper struct {
	// contains filtered or unexported fields
}

SerializeHelper PHP 序列化辅助工具

func NewSerializeHelper

func NewSerializeHelper() *SerializeHelper

NewSerializeHelper 创建序列化辅助工具实例

func (*SerializeHelper) ConvertJSONToSerialized

func (h *SerializeHelper) ConvertJSONToSerialized(jsonData string) (string, error)

ConvertJSONToSerialized 将 JSON 转换为 PHP 序列化格式 参数:

  • jsonData: JSON 字符串

返回:

  • string: PHP 序列化字符串
  • error: 转换失败时的错误信息

func (*SerializeHelper) ConvertSerializedToJSON

func (h *SerializeHelper) ConvertSerializedToJSON(serializedData string) (string, error)

ConvertSerializedToJSON 将 PHP 序列化格式转换为 JSON 参数:

  • serializedData: PHP 序列化字符串

返回:

  • string: JSON 字符串
  • error: 转换失败时的错误信息

func (*SerializeHelper) GetSerializedDataInfo

func (h *SerializeHelper) GetSerializedDataInfo(data string) (string, error)

GetSerializedDataInfo 获取序列化数据的信息 参数:

  • data: 序列化数据

返回:

  • string: 数据信息
  • error: 获取信息失败时的错误信息

func (*SerializeHelper) IsValidSerializedData

func (h *SerializeHelper) IsValidSerializedData(data string) bool

IsValidSerializedData 检查是否为有效的序列化数据 参数:

  • data: 要检查的数据

返回:

  • bool: 是否为有效的序列化数据

func (*SerializeHelper) Serialize

func (h *SerializeHelper) Serialize(data string) (string, error)

Serialize 序列化数据为 PHP 格式 参数:

  • data: 要序列化的数据(JSON 字符串格式)

返回:

  • string: 序列化后的字符串
  • error: 序列化失败时的错误信息

func (*SerializeHelper) SerializeArray

func (h *SerializeHelper) SerializeArray(items []string) (string, error)

SerializeArray 序列化数组 参数:

  • items: 数组项

返回:

  • string: 序列化后的字符串
  • error: 序列化失败时的错误信息

func (*SerializeHelper) SerializeMap

func (h *SerializeHelper) SerializeMap(data map[string]interface{}) (string, error)

SerializeMap 序列化映射 参数:

  • data: 映射数据

返回:

  • string: 序列化后的字符串
  • error: 序列化失败时的错误信息

func (*SerializeHelper) Unserialize

func (h *SerializeHelper) Unserialize(serializedData string) (string, error)

Unserialize 反序列化 PHP 格式的数据 参数:

  • serializedData: 序列化的数据字符串

返回:

  • string: 反序列化后的 JSON 字符串
  • error: 反序列化失败时的错误信息

Jump to

Keyboard shortcuts

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