jsoniterx

package module
v0.0.0-...-a1680a0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 4 Imported by: 0

README

jsoniterx

Extension for json-iterator/go.

Tags

time.Time
Name description
format A string for format. more details.
location A string for Location.

Example

package main

import (
	"fmt"
	"time"

	jsoniter "github.com/json-iterator/go"

	"github.com/ynqa/jsoniterx"
)

type Example struct {
	Time time.Time `json:"time" format:"2006-01-02 15:04:05" location:"Asia/Tokyo"`
}

func main() {
	json := jsoniter.ConfigCompatibleWithStandardLibrary
	json.RegisterExtension(jsoniterx.TimePlugin())

	var e Example
	str := `{"time": "2019-01-01 12:00:00"}`
	if err := json.Unmarshal([]byte(str), &e); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(e.Time)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TimePlugin

func TimePlugin() *timePlugin

Types

type Binder

type Binder func(*jsoniter.Binding)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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