github gitlab twitter email
Send Json to Go Http Handler func
Mar 1, 2018
One minute read

I’m building a webapp(to pratice my go skills) which will receive and send json.

On the frontend when I was building a json string by hand and using JSON.parse to send it to Go I’ve just got errors on decoding json.

What I’ve found?

Create a new object then use JSON.stringfy():

var requestObj = {};

requestObj.Foo = "space";
requestObj.Bar = "Z";

var requestJson = JSON.stringfy(requestObj);

Your Go handler func will appreciate. And everyone will be happy.

(I “invested” 3 hours of my time to find that it was the javascript part of my code that was wrong. Oh my!. And yes, my js skills are at very, very basic level)


Tags: go javascript json jquery


Back to posts