go_json.go
This file
Path
codec/json/go_json.go
42 lines · 898 bytes · Go
Last changed by
feat: support custom json codec at runtime (#3391)Timbefore adoption688a429
History of this fileTake it
1// Copyright 2025 Gin Core Team. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45//go:build go_json67package json89import (10 "io"1112 "github.com/goccy/go-json"13)1415// Package indicates what library is being used for JSON encoding.16const Package = "github.com/goccy/go-json"1718func init() {19 API = gojsonApi{}20}2122type gojsonApi struct{}2324func (j gojsonApi) Marshal(v any) ([]byte, error) {25 return json.Marshal(v)26}2728func (j gojsonApi) Unmarshal(data []byte, v any) error {29 return json.Unmarshal(data, v)30}3132func (j gojsonApi) MarshalIndent(v any, prefix, indent string) ([]byte, error) {33 return json.MarshalIndent(v, prefix, indent)34}3536func (j gojsonApi) NewEncoder(writer io.Writer) Encoder {37 return json.NewEncoder(writer)38}3940func (j gojsonApi) NewDecoder(reader io.Reader) Decoder {41 return json.NewDecoder(reader)42}