I am trying to create this output when calling my GOlang API.
{
"jsonrpc": "2.0",
"result": [
false,
"",
"",
""
],
"id": 1
}
So far, using
type JSONRpc struct {
Id json.RawMessage `json:"id,omitempty"`
Version string `json:"jsonrpc,omitempty"`
Result interface{} `json:"result"`
}
message := JSONRpc{Id: id, Version: "2.0", Result: fmt.Sprintf("[%t, %q, %q, %q]", false, "", "", "")}
Encode(&message)
and
[%t, %s, %s, %s]
I am able to get
{
"id": 1,
"jsonrpc": "2.0",
"result": "[false, \"\", \"\", \"\"]"
}
and
{
"id": 1,
"jsonrpc": "2.0",
"result": "[false, , , ]"
}
How do I get a perfect
{
"jsonrpc": "2.0",
"result": [
false,
"",
"",
""
],
"id": 1
}