encoding

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package encoding provides some useful functions for encoding and decoding objects

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(encodeStr string, obj interface{}) error

Base64Decode decode encodeStr using base64, and then use json to convert to obj.

func Base64Encode

func Base64Encode(obj interface{}) (string, error)

Base64Encode convert obj to json string, and then encode it with base64.

func ObjectToMap

func ObjectToMap(obj interface{}) map[string]interface{}

ObjectToMap convert an object to a map[string]interface{}

Types

type JsonPath

type JsonPath struct {
	// PathFormat is the format of the path
	PathFormat func(string) string
}

JsonPath object for json-path encoding and decoding

func NewJsonPath

func NewJsonPath() JsonPath

NewJsonPath construct json path

func (JsonPath) Decode

func (p JsonPath) Decode(obj interface{}, data map[string]string) error

Decode decode json path to obj

func (JsonPath) Encode

func (p JsonPath) Encode(obj interface{}) map[string]string

Encode encode obj to json path

type Node

type Node struct {
	Name   string
	Value  string
	Type   NodeType
	Childs map[string]*Node
}

func NewRootNode

func NewRootNode() *Node

func (*Node) Get

func (n *Node) Get(paths []string) *Node

func (*Node) Json

func (n *Node) Json() string

func (*Node) Set

func (n *Node) Set(path string, value string)

type NodeType

type NodeType string
const (
	NodeTypeRoot   NodeType = "root"
	NodeTypeArray  NodeType = "array"
	NodeTypeObject NodeType = "object"
	NodeTypeValue  NodeType = "value"
)

Jump to

Keyboard shortcuts

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