encoding/json: explain how to properly Marshall RawMessage #16648
Labels
Milestone
Comments
cc @ccirello |
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 |
CL https://golang.org/cl/26692 mentions this issue. |
Back to the example that @hydroflame gave, here is another way it works. https://play.golang.org/p/sMKGqodDde So is it better to just always pass the pointer of the thing to |
I believe it to be a bit misleading to say that is better to call always |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
. UsingRawMessage
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: