stt

package
v0.0.0-...-4cd40bb Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

STT serialize

Douyu's STT is a method of serializing structured data

  1. Keys and values are directly split using '@='
  2. Array uses '/' to separate elements
  3. '/' in key or value is encoded as '@S'
  4. '@' in key or value is encoded as '@A'

Example:

(1) key-value:key1@=value1/key2@=value2/key3@=value3/ 
(2) Array:value1/value2/value3/ 

Import

import "github.com/DreamedOfMe/barrage-kit/stt"

Demo

package main

import (
   "fmt"
   "github.com/DreamedOfMe/barrage-kit/stt"
)

func main() {
   fmt.Println(stt.Decode("a@A=b@Sc@A=d@S/d/v/"))
   fmt.Println(stt.Decode("a@=b/c@=d/"))
   fmt.Println(stt.Encode(map[string]interface{}{
   	"type": "joingroup",
   	"rid":  "123456",
   	"gid":  "-9999",
   }))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(input string) interface{}

func Encode

func Encode(input interface{}) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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