modulepackage
1.0.0
Repository: https://github.com/liamylian/json-hashids.git
Documentation: pkg.go.dev
# README
json-hashids
A json iterator extension that marshal integer to short unique id
Usage
100% compatibility with standard lib
Replace
import "encoding/json"
json.Marshal(&data)
json.Unmarshal(input, &data)
with
import "github.com/liamylian/jsonhashids"
var json = NewConfigWithHashIDs("abcdefg", 10)
json.Marshal(&data)
json.Unmarshal(input, &data)
Example
package main
import(
"fmt"
"github.com/liamylian/json-hashids"
"time"
)
var json = jsonhashids.NewConfigWithHashIDs("abcdefg", 10)
type Book struct {
Id int `json:"id" hashids:"true"`
Name string `json:"name"`
}
func main() {
book := Book {
Id: 1,
Name: "Jane Eyre",
}
bytes, _ := json.Marshal(book)
// output: {"id":"gYEL5rKBnd","name":"Jane Eyre"}
fmt.Printf("%s", bytes)
}
# Functions
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
# Structs
No description provided by the author