#How to create a string that says null, but without string quotes?

2 messages · Page 1 of 1 (latest)

knotty summit
#

Hey, I just need a constant variable in a json like:

"testvar":null,"test":"test","confirm":false

If I do testRequest struct like this:

type TestRequest struct{
  test string
  testvar string
  confirm bool
}

and make a json like this:

testReq := TestRequest{
  test: test
  testvar: "null"
  confirm: false
}
body, _ := json.Marshal(testReq)
fmt.Println(string(body))

it prints:

"testvar":"null","test":"test","confirm":false

but i need to shave quotes around "null", like how there is no quotes at false. is this possible?

#

sorry for kinda lengthy msg.