The encoding/json package connects Go values with JSON text. Exported struct fields participate in encoding, and tags define their wire names. Decoding into a struct fills omitted fields with zero values, so required-field validation is a separate step. The basic Unmarshal function accepts unknown fields; use a decoder with DisallowUnknownFields when your boundary needs a stricter contract. A JSON number can also exceed an integer field, which must remain an error instead of becoming a rounded value. You will decode original stock messages and return a small public representation. The checks compare decoded meaning where field order is irrelevant. They also include malformed input, an omitted optional value and a field that must stay out of the encoded result.
Use the JSON field tags.