Skip to content

Merge duplicate struct definitionsΒ #65

@DCRichards

Description

@DCRichards

Where there are multiple properties which reuse the same nested properties, the corresponding struct definition should be flattened. Take the following JSON:

{
   "filter":{
      "sitereference":[
         {
            "value":"shshs"
         }
      ],
      "transactionreference":[
         {
            "value":"3-64-25205"
         }
      ]
   }
}

Expected output:

type AutoGenerated struct {
	Filter Filter `json:"filter"`
}

type FilterAutoGenerated struct {
	Value string `json:"value"`
}

type Filter struct {
	Sitereference        []FilterAutoGenerated `json:"sitereference"`
	Transactionreference []FilterAutoGenerated `json:"transactionreference"`
}

Actual output:

type AutoGenerated struct {
	Filter Filter `json:"filter"`
}

type Sitereference struct {
	Value string `json:"value"`
}

type Transactionreference struct {
	Value string `json:"value"`
}

type Filter struct {
	Sitereference        []Sitereference        `json:"sitereference"`
	Transactionreference []Transactionreference `json:"transactionreference"`
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions