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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -