json.Decode or json.Marshal

Hello everyone !
I have a simple question.
Imagen you get a json data from your frontend and your backend in golang.
When i should use Marshal and when i should use Decode ?
:slight_smile:

Based on this article you may want to consider using Marshal and Unmarshal instead of the decoder/encoders.

That article is rather outdated and you can use either. If you have reason to expect broken JSON and want to print a reasonable error message you might prefer having the JSON in a byte slice and using unmarshal.

Thank you all for you answer . Helped me very much.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.