Hello Gophers
I use RawMessage to precompute part of a json message.
RawMessage is a raw encoded JSON object. It implements Marshaler and Unmarshaler and can be used to delay JSON decoding or precompute a JSON encoding.
Following code shows the problem:
package main
import "encoding/json"
type S struct{ R json.RawMessage }
func main() {
s := S{json.RawMessage([]byte(`42`))}
b, _ := json.Marshal(s)
println(string(b)) // {"R":"NDI="} Expected: {"R":42}
}
Is this behaviour expected?
I have made a patch to go tip to fix this, should i send it for review?
Thank you for this great language!
Ron