golang为什么不解码json post?

golang为什么不解码json post?,json,http,parsing,go,Json,Http,Parsing,Go,嘿,我正在开发一个ios应用程序,我的服务器能够识别对本地主机的post请求,但它没有解码,或者可能是另一个问题,我得到的答案是&{0xc000a8300 false true{0 0}true false false 0x12504c0}&{0xc000ca380[123 34 116 105 116 108 101 34 58 34 114 111 100 111 34 125]{[123 34 116 105 116 108 101 34 58 34 114 111 100 111 34

嘿,我正在开发一个ios应用程序,我的服务器能够识别对本地主机的post请求,但它没有解码,或者可能是另一个问题,我得到的答案是
&{0xc000a8300 false true{0 0}true false false 0x12504c0}&{0xc000ca380[123 34 116 105 116 108 101 34 58 34 114 111 100 111 34 125]{[123 34 116 105 116 108 101 34 58 34 114 111 100 111 34 125]17 10{0x10ec820 true[]0}{[]}false false}16 0{0x10ec820 true[]16}0[]}
im打印3个值这是我的代码:

package main

import (
    "encoding/json"
    "log"
    "net/http"
)
type test_struct struct {
    title string
    body string
}


func main() {
    http.HandleFunc("/", test) // deal
    http.ListenAndServe(":8080", nil)
   
}
func test(w http.ResponseWriter, r *http.Request) {
    var t test_struct
    decoder := json.NewDecoder(r.Body)
    err := decoder.Decode(&t)
    if err != nil {
        panic(err)
    }
    log.Println(r.Body, decoder, t.title)
    
}

顺便说一句,我知道客户端发送数据没有问题,因为我已经用node js测试过了,可能问题出在正文解析器上。谢谢你,你几乎什么都做对了。请更改结构,你必须使用大写字母(公开)


就是这样。

thhanks!我现在正试图打印我写的fmt.Fprintf(w,“test\u struct:%+v”,t.Title),但它给出了EOF,请看那个例子。也许这有帮助。
type TestStruct struct {
    Title string
    Body  string
}