Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Bug:Dead Loop Two when Two structs are mutually dependent。 #718

@jau1jz

Description

@jau1jz

package main

import (
"log"

json "github.com/json-iterator/go"

)

// Implement interface
type Address struct {
City string
State string
Post string
*Person
}

// Implement interface
type Person struct {
Name string
Age int
*Address
}

func main() {
A := Address{
City: "New York",
State: "NY",
}
p := Person{
Name: "Alice",
Age: 30,
Address: &A,
}
A.Person = &p

marshal, err := json.Marshal(&p)
if err != nil {
	log.Printf("Marshal failed: %v", err)
} else {
	log.Printf("format: %s", marshal)
}

}

Address include Person Point
Person include Address Point
json "github.com/json-iterator/go"

Image

Use"encoding/json"

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions