Package Mainimport ("Encoding/json"//JSON Tool "FMT")//github.com/pquerna/ffjson/ffjson//this JSON tool is much more efficient than its own JSON /and interface, exactly, type worker struct {Name string ' JSON: ' worker_name '///Convert to JSON format, key is Worker_name Sex string salay int32//Note Meaning, JSON does not operate on this property because Salay is lowercase}func main () {///1, array form, encoded by x: = [5]int{1, 2, 3, 4, 5} bytes, E: = json. Marshal (x) if E! = nil {panic (e)} fmt. Println (String (bytes))//[1,2,3,4,5]//2, for map type, json var stu = map[string]string{} stu = Make (map[string]string) stu[" Name "] =" Beijing "Stujson, err: = json. Marshal (stu) if err! = Nil {panic (err)} FMT. Println (String (Stujson))//{"name": "Beijing"}//3, JSON-encoded struct object wk: = worker{Name: "Xiaozhang", Sex: "Male", Sala Y:34,} wrjson, ERR2: = json. Marshal (wk) if err2! = nil {panic (ERR2)} fmt. Println (String (Wrjson))//{"Worker_name": "Xiaozhang", "Sex": "Male"}//4, decoding the Wrjson var w interface{}//Declaring a interface That stores the decoded value JSON. Unmarshal (Wrjson, &w) fmt. PRINTF ("---JSON format decoding---->%v", W)//map[worker_nAme:xiaozhang Sex:male]}
==================================
package mainimport ( "crypto/md5" "fmt")//注意,md5是不逆的//md5的格式,基本上是一样的//使用时,按照下面的格式,copy就可以了。func main() { Md5Inst := md5.New() Md5Inst.Write([]byte("admin")) Result := Md5Inst.Sum([]byte("")) fmt.Printf("%x\n\n", Result)}
JSON MD5 of Golang language