I'm attempting to build a JSON payload for a POST request:
var payload = []byte(`{"foo":"bar", "hello":"world"}`)
However, I would like the values to be interpolated from an existing string. I've tried to use %s
, but this is obviously not syntactically correct:
var payload = []byte(`{"foo":%s, "hello":%s}`, val1, val2)
Feels like I'm going about this the entirely wrong way. Any suggestions would be appreciated. Thanks.