Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.18 KB

README.md

File metadata and controls

47 lines (38 loc) · 1.18 KB

JSONT

GoDoc Latest Version codecov Go Report Card

A really simple JSON templating utility...

package main

import "github.com/go-andiamo/jsont"

var myTemplate = jsont.MustCompileTemplate(`{
    "foo": ?,
    "bar": ?
}`)

func main() {
    str, _ := myTemplate.String("foo value", 1)
    println(str)
}

produces...

{
    "foo": "foo value",
    "bar": 1
}

Or using named arg markers...

package main

import "github.com/go-andiamo/jsont"

var myTemplate = jsont.MustCompileNamedTemplate(`{
    "foo": ?foo,
    "bar": ?bar
}`)

func main() {
    str, _ := myTemplate.String(map[string]interface{}{"foo": "foo value", "bar": 1})
    println(str)
}