Skip to content

lizongying/go-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-json

Json Selector in Golang for Easier Use.

go-json

document

中文

Install

go get -u github.com/lizongying/go-json@latest

Usage

package main

import (
	"fmt"
	"github.com/lizongying/go-json/gjson"
)

func main() {
	html := `{"name":{"first":"Janet","last":"Prichard"},"age":47, "a": [2,3]}`
	s, _ := gjson.NewSelectorFromStr(html)

	i := s.One(`age`).Int()
	//47
	fmt.Printf("%+v\n", i)

	u64 := s.One(`age`).Int64()
	//47
	fmt.Printf("%+v\n", u64)

	m := s.Many(`a`)
	n := m[0].Float64()
	//2
	fmt.Println(n)
}

Releases

No releases published

Packages

No packages published

Languages