Adds directive syntax to the Jsonic JSON
parser. A directive is a token sequence (e.g. @name, add<1,2>) that
triggers custom parsing behaviour. TypeScript and Go ports share the
same API shape and test specs.
This project's documentation follows the Diátaxis framework. Each section has one job — pick the one that matches what you're trying to do.
| If you want to… | Read |
|---|---|
| Build your first directive step-by-step | Tutorial |
| Solve a specific problem | How-to guides |
| Look up an option, type, or default | Reference |
| Understand how the plugin works internally | Explanation |
import{Jsonic}from'jsonic'import{Directive}from'@jsonic/directive'constj=Jsonic.make().use(Directive,{name: 'upper',open: '@',action: (rule)=>(rule.node=String(rule.child.node).toUpperCase()),})j('[@a, @b, 1]')// → ['A', 'B', 1]import (
jsonic "github.com/jsonicjs/jsonic/go"
directive "github.com/jsonicjs/directive/go"
)
j:=jsonic.Make()
directive.Apply(j, directive.DirectiveOptions{
Name: "upper",
Open: "@",
Action: func(r*jsonic.Rule, _*jsonic.Context) {
r.Node=strings.ToUpper(fmt.Sprintf("%v", r.Child.Node))
},
})
j.Parse("[@a, @b, 1]") // → []any{"A", "B", float64(1)}MIT — see LICENSE.