json

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: BSD-3-Clause Imports: 4 Imported by: 3

README

simple-json GoDoc

A simple json module in Go.

TODO

  • array interface
  • map interfacepackage json // import "github.com/chuqingq/simple-json"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Json

type Json struct {
	sjson.Json
}

Json Json

func FromBytes

func FromBytes(data []byte) (*Json, error)

FromBytes parse []byte to Json

func FromFile

func FromFile(filepath string) (*Json, error)

FromFile parse json from filepath

func FromString

func FromString(s string) (*Json, error)

FromString parse string to Json

func FromStruct

func FromStruct(v interface{}) *Json

FromStruct parse struct to Json, like json.Marshal()

func New

func New() *Json

New new a Json

func (*Json) Array

func (m *Json) Array() []Json

func (*Json) Get

func (m *Json) Get(path string) *Json

Get 按path获取Json中的内容。path是"key1.key2.key3"的形式

func (*Json) Map

func (m *Json) Map(path string, def ...map[string]interface{}) map[string]interface{}

func (*Json) Set

func (m *Json) Set(path string, v interface{})

Set path是"key1.key2.key3"的形式,v支持string、bool、int、map[string]interface{}、[]interface{}

func (*Json) ToBytes

func (m *Json) ToBytes() []byte

ToBytes Json to []byte

func (*Json) ToFile

func (m *Json) ToFile(filepath string) error

ToFile save json to filepath

func (*Json) ToString

func (m *Json) ToString() string

ToString Json to string

func (*Json) ToStruct

func (m *Json) ToStruct(v interface{}) error

ToStruct parse Json to struct, like json.Unmarshal()

Jump to

Keyboard shortcuts

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