decoder_vector

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: MIT Imports: 9 Imported by: 1

README

Decoder vector bindings

Provide vector and vector_inspector features to use in dyntpl.

Usage
package main

import (
	"github.com/koykov/decoder"
	"github.com/koykov/inspector/testobj"
	"github.com/koykov/inspector/testobj_ins"

	_ "github.com/koykov/decoder_vector"   // register vector bindings
	_ "github.com/koykov/vector_inspector" // register vector inspector
)

const (
	dec = `ctx.data = vector::parseJSON(source).(vector)
obj.Name = data.x.y.z`
	json = `{"x":{"y":{"z":"foobar"}}}`
)

func main() {
	ruleset, _ := decoder.Parse([]byte(dec))
	decoder.RegisterDecoder("example", ruleset)
	ctx := decoder.NewCtx()
	var obj testobj.TestObject
	ctx.SetStatic("source", json)
	ctx.Set("obj", &obj, testobj_ins.TestObjectInspector{})
	_ = decoder.Decode("example", ctx)
	println(string(obj.Name)) // output: foobar
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownType = errors.New("unknown vector type")

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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