You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use gojson to generate structs for an array of items, which may or may not contain (disjunct) keys with different sub-objects. Example (let's call this test.json):
In my original input these are one object per line, but as gojson can not handle this I have converted the input to an array instead. While this format can be well processed using the default settings:
$ cat test.json | gojson
package main
type Foo []struct {
Foo struct {
Bar int64 `json:"bar"`
Baz int64 `json:"baz"`
Xx struct {
Foo string `json:"foo"`
} `json:"xx"`
Yy struct {
Bar string `json:"bar"`
} `json:"yy"`
} `json:"foo"`
}
there's a problem when trying to use -subStruct:
$ cat test.json | gojson -subStruct
package main
type Foo []struct {
Foo Foo_sub3 `json:"foo"`
}
The substructs just are not printed. I would have expected an output similar to what I would get from a non-array input:
$ cat test2.json
{"foo": {"bar": 2, "baz": 4, "xx": {"foo": "bar"}}}
$ cat test2.json | gojson -subStruct
package main
type Foo struct {
Foo Foo_sub2 `json:"foo"`
}
type Foo_sub2 struct {
Bar int64 `json:"bar"`
Baz int64 `json:"baz"`
Xx Foo_sub1 `json:"xx"`
}
type Foo_sub1 struct {
Foo string `json:"foo"`
}
where the referenced substructs are also printed in the actual output.
The text was updated successfully, but these errors were encountered:
I'm trying to use gojson to generate structs for an array of items, which may or may not contain (disjunct) keys with different sub-objects. Example (let's call this
test.json
):In my original input these are one object per line, but as gojson can not handle this I have converted the input to an array instead. While this format can be well processed using the default settings:
there's a problem when trying to use
-subStruct
:The substructs just are not printed. I would have expected an output similar to what I would get from a non-array input:
where the referenced substructs are also printed in the actual output.
The text was updated successfully, but these errors were encountered: