encoding/json has an example for Unmarshalling json.RawMessage but not for Marshalling it. The example doesn't point out that Marshalling requires a *RawMessage. Using RawMessage doesn't give the expected results and it's not immediately obvious why. https://play.golang.org/p/A1nbikzzVY
The text was updated successfully, but these errors were encountered:
I think it makes sense adding such example, namely because the documentation says it can be used both to delay parsing as much to precompute a JSON encoding - the latter missing. Likely something along the lines: https://play.golang.org/p/OdTp9Dh0o1
I believe it to be a bit misleading to say that is better to call always json.Marshal(&v). json.Marshal will execute json.Marshaler of pointers, otherwise it will just take the concrete type and marshal it.