Skip to content

Embedded structs are not being serialized. #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
xomaczar opened this issue Nov 4, 2015 · 9 comments
Open

Embedded structs are not being serialized. #21

xomaczar opened this issue Nov 4, 2015 · 9 comments
Assignees

Comments

@xomaczar
Copy link

xomaczar commented Nov 4, 2015

type Foo struct {
     Name      string    `jsonapi:"attr,name"`
     CreatedOn time.Time `jsonapi:"attr,createdOn"`
}

type Bar struct {
     Foo    
     ID   string `jsonapi:"primary,bars"`
     Last string `jsonapi:"attr,last"`
}

Marshaling Bar struct, ignores embedded fields from Foo (i.e. name, createdOn)

@shwoodard
Copy link
Contributor

I don't believe the stdlib json parser even supports this.

@xomaczar
Copy link
Author

@shwoodard it does - json.Marshal(Bar{}) would result in json with Name, CreatedOn, ID, Last included.

@xomaczar xomaczar reopened this Jan 13, 2016
@shwoodard
Copy link
Contributor

@xomaczar Wanna take a crack at this and send a PR?

shwoodard pushed a commit that referenced this issue Apr 10, 2016
shwoodard pushed a commit that referenced this issue Apr 10, 2016
@brandonbloom
Copy link
Contributor

I'd like this too. Looks like you've started working on it. Anything we can do to help?

@cfatt10
Copy link

cfatt10 commented Dec 6, 2016

I am running into this issue in my code. Has any more progress been made, or a workaround discovered?

@xomaczar
Copy link
Author

xomaczar commented Dec 6, 2016

Try https://github.com/manyminds/api2go

@svperfecta
Copy link

I think we should close this one?

This was referenced Feb 6, 2017
@gonzalo-bulnes
Copy link

Hello! I can confirm that #78 works as expected.

@pioz
Copy link

pioz commented Oct 11, 2019

Any update for this issue? When do you think that the branch feature/embeded-structs will be merged to master?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants