Skip to content

Commit d4a1d39

Browse files
committed
add test for mergable objects within arrays
1 parent 2a1a27b commit d4a1d39

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

��json-to-go.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ function testFiles() {
159159
const testCases = [
160160
"duplicate-top-level-structs",
161161
"double-nested-objects",
162+
"array-with-mergable-objects",
162163
];
163164

164165
for (const testCase of testCases) {

‎tests/array-with-mergable-objects.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
type AutoGenerated struct {
2+
Booleanfield bool `json:"booleanfield"`
3+
Inconsistentarray []Inconsistentarray `json:"inconsistentarray,omitempty"`
4+
Date string `json:"date,omitempty"`
5+
}
6+
type Features struct {
7+
Age int `json:"age,omitempty"`
8+
Height int `json:"height,omitempty"`
9+
Gender string `json:"gender,omitempty"`
10+
}
11+
type Inconsistentarray struct {
12+
ID int `json:"id,omitempty"`
13+
Name string `json:"name,omitempty"`
14+
Features Features `json:"features,omitempty"`
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"booleanfield": true,
3+
"inconsistentarray": [
4+
{
5+
"id": 1,
6+
"name": "John Doe",
7+
"features": {
8+
"age": 49,
9+
"height": 175
10+
}
11+
},
12+
{
13+
"id": 2,
14+
"name": "Jane Doe",
15+
"features": {
16+
"height": 164
17+
}
18+
},
19+
{
20+
"id": 3,
21+
"name": "John Doe",
22+
"features": {
23+
"gender": "unknown"
24+
}
25+
}
26+
],
27+
"date": "2024-07-22"
28+
}

0 commit comments

Comments
 (0)