Merge duplicate struct definitions
See original GitHub issueWhere 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"`
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
SwiftUI duplicate in struct and delete and merge them by ...
I have requirement string for the drinks, eg two glass of coke, one no ice and another with ice. I want if no...
Read more >How can I concatenate or merge two structures? - MathWorks
I would like to merge two structures into a new structure containing all the fields of the two original structures.
Read more >Duplicate Fields - CUE lang
CUE allows duplicated field definitions as long as they don't conflict. ... For structs, fields are merged and duplicated fields are handled recursively....
Read more >Remove duplicates from sorted array - GeeksforGeeks
Given a sorted array, the task is to remove the duplicate elements from the array. Examples: Input : arr[] = {2, 2, 2,...
Read more >URL Canonicalization and the Canonical Tag | Documentation
When a site has duplicate content, Google chooses the canonical URL. Learn more about canonical URLs and how to consolidate duplicate URLs.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just encountered this and came to file this exact issue.
I’d be willing to take a look (given the tag).
Incidentally, this tool is a boon to anyone using a public API that produces extremely verbose structures. Thank you! ❤️ 🙏
@michaelsanford Are you still working on this?