In Go, the ________ interface allows you to define custom JSON marshaling and unmarshaling logic.
- CustomJSON
- JSONCustom
- JSONable
- Marshaler
The correct interface in Go that allows you to define custom JSON marshaling and unmarshaling logic is the json.Marshaler and json.Unmarshaler interfaces. By implementing these interfaces for a custom type, you can control how instances of that type are converted to JSON when marshaling and how JSON data is converted back to instances of that type when unmarshaling. This customization is useful when you need to handle special cases or non-standard JSON formatting requirements.
Loading...
Related Quiz
- What is the difference between 'nil' and 'null' in Go pointers?
- The _____ command is used to populate the vendor directory with the exact versions of dependencies specified in the go.mod file.
- How does Go implement struct inheritance?
- What are the benefits of using prepared statements in Go?
- In a Go program utilizing channels, how would you handle the scenario where one of the channels is closed prematurely?