php - golang, revel, How to parse post json? -
i'm rather new in golang, i'm trying hard..
i'm trying send json post request revel controller, , parse on revel side.
but while getting result cannot unmarshal it... i'm sending array
json_encode(array("one","two","three"))
but can't find correct way work such data. i'm not sure need make json before sending or not..
func (c kpictrl) getdata() revel.result { content, _ := ioutil.readall(c.request.body) ... return c.renderjson(content) }
returns
"wyjvbmuilcj0d28ilcj0ahjlzsjd"
i tried use json.unmarshal returns errors.. best practice work post data sent curl revel controller?
just use standart json decoder:
var content []string err := json.newdecoder(c.request.body).decode(&content) if err != nil { log.fatal("json decode error: ", err) } defer c.request.body.close() fmt.println(content)
Comments
Post a Comment