go-scan: github.com/mattn/go-scan Index | Examples | Files

package scan

import "github.com/mattn/go-scan"


package main

import (

var js = strings.NewReader(`
	"foo": {
		"bar": [
				"baz": "bbb",
				"noo": 3 
				"maz": true,
				"moo": ["foo", "bar"]
		"boo": {
			"bag": "ddd",
			"bug": "ccc"

func main() {
    var s []string
    if err := scan.ScanJSON(js, "/foo/bar[1]/moo", &s); err != nil {
    fmt.Println(s[0]) // should be "foo"
    fmt.Println(s[1]) // should be "bar"



Package Files


func Scan Uses

func Scan(v interface{}, t interface{}) (err error)

Scan work to scan any type to specified type

func ScanJSON Uses

func ScanJSON(r io.Reader, p string, t interface{}) (err error)

ScanJSON work as same sa ScanTree. it allow to give Reader.

func ScanTree Uses

func ScanTree(v interface{}, p string, t interface{}) (err error)

ScanTree work to scan value to specified value with the path

type Any Uses

type Any interface{}

Any provide interface to scan any types.

Package scan imports 6 packages (graph) and is imported by 8 packages. Updated 2016-10-28. Refresh now. Tools for package owners.