Skip to content

Handling of embedded fields is different from "encoding/json" #22

@u1aryz

Description

@u1aryz

For example code

package main

import (
	"os"

	"github.com/goccy/go-json"
)

type Foo struct {
	ID string `json:"id"`
}

type Bar struct {
	Foo
	Name string `json:"name"`
}

func main() {
	bar := new(Bar)
	bar.ID = "id_hoge"
	bar.Name = "name_fuga"
	json.NewEncoder(os.Stdout).Encode(bar)
}

Result

  • goccy/go-json
{"Foo":{"id":"id_hoge"},"name":"name_fuga"}
  • encoding/json
{"id":"id_hoge","name":"name_fuga"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions