# Codificação JSON (Go) > json.Marshal, json.Unmarshal, struct tags, custom marshaling, streaming, RawMessage - 20 perguntas de entrevista - Mid-Level - [Perguntas de entrevista: Go](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista.md) ## 1. Qual função permite codificar uma struct Go em JSON? **Resposta** json.Marshal codifica uma struct Go em bytes JSON. Essa função lê os struct tags para personalizar a serialização (renomeação, omissão de campos). Para streaming em io.Writer, usar json.NewEncoder evita criar um buffer intermediário na memória. ## 2. Qual função permite decodificar JSON em uma struct Go? **Resposta** json.Unmarshal decodifica bytes JSON em uma struct Go. É preciso passar um ponteiro para a struct de destino para que os dados sejam escritos corretamente. Para streaming a partir de io.Reader, json.NewDecoder é mais eficiente pois evita carregar todo o JSON na memória. ## 3. Qual struct tag JSON permite renomear um campo durante a serialização? **Resposta** A tag json:"custom_name" permite renomear um campo durante a serialização JSON. Por exemplo, um campo UserID pode se tornar user_id em JSON. Isso é útil para respeitar as convenções de nomenclatura (snake_case em JSON vs CamelCase em Go). ## Mais 17 perguntas disponiveis - Qual struct tag JSON exclui completamente um campo da serialização? - Qual struct tag JSON permite omitir um campo se seu valor estiver vazio? Cadastre-se gratis: https://sharpskill.dev/pt/login ## Outros temas de entrevista Go - [Fundamentos de Go](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/go-basics.md): 25 perguntas, Junior - [Estruturas de dados em Go](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/go-data-structures.md): 20 perguntas, Junior - [Interfaces em Go](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/go-interfaces.md): 18 perguntas, Junior - [Tratamento de erros](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/error-handling.md): 20 perguntas, Junior - [Goroutines básicas](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/goroutines-basics.md): 20 perguntas, Junior - [Channels](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/channels.md): 22 perguntas, Junior - [Go Modules](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/go-modules.md): 18 perguntas, Mid-Level - [Servidor HTTP](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/http-server.md): 24 perguntas, Mid-Level - [Cliente HTTP](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/http-client.md): 18 perguntas, Mid-Level - [Database/SQL](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/database-sql.md): 22 perguntas, Mid-Level - [Pacote context](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/context-package.md): 20 perguntas, Mid-Level - [Testing](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/testing.md): 22 perguntas, Mid-Level - [Padrões de concorrência](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/concurrency-patterns.md): 24 perguntas, Mid-Level - [Primitivas de sincronização](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/sync-primitives.md): 22 perguntas, Mid-Level - [Frameworks web Go](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/go-web-frameworks.md): 20 perguntas, Mid-Level - [Design de API REST](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/rest-api-design.md): 20 perguntas, Mid-Level - [gRPC](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/grpc.md): 22 perguntas, Mid-Level - [Reflection](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/reflection.md): 20 perguntas, Senior - [Gerenciamento de memória](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/memory-management.md): 24 perguntas, Senior - [Otimização de desempenho](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/performance-optimization.md): 22 perguntas, Senior - [Generics](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/generics.md): 20 perguntas, Senior - [Go Design Patterns](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/design-patterns.md): 24 perguntas, Senior - [Microservices](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/microservices.md): 24 perguntas, Senior - [Segurança e autenticação](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/security-authentication.md): 24 perguntas, Senior - [Docker & Containerization](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/docker-containerization.md): 20 perguntas, Senior - [Kubernetes Basics](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/kubernetes-basics.md): 22 perguntas, Senior - [Go Avançado](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/advanced-go.md): 20 perguntas, Senior - [Desenvolvimento de CLI](https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/cli-development.md): 20 perguntas, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/pt/technologies/go/perguntas-entrevista/json-encoding