Skip to content
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

slice, array: interface must be a pointer to a struct #6

Closed
themihai opened this issue Jul 25, 2016 · 8 comments
Closed

slice, array: interface must be a pointer to a struct #6

themihai opened this issue Jul 25, 2016 · 8 comments

Comments

@themihai
Copy link

themihai commented Jul 25, 2016

It seems slice and array types are supported only on struct properties.

@deankarn deankarn self-assigned this Jul 25, 2016
@deankarn deankarn added this to the v1 milestone Jul 25, 2016
@deankarn
Copy link

Hey @themihai

currently that is correct, as the description states Package form Decodes url.Values into struct values

however, it actually might not be that hard to also decode directly into variables such as arrays or maps.

I will look into the possibility of adding this tonight after I get off work; thanks for the idea.

@themihai
Copy link
Author

You're right! I was quick to jump on the "Supported Types" section instead to read documentation more thoroughly. Support for direct values would be nice as it would put query encoding on par with the other formats(i.e. json).

@themihai
Copy link
Author

I've tried a quick decoding implementation of direct struct slices(just hooked-up the slice decoding method into the main Decode function) but unfortunately some tests(see the commented out lines) are failing. These seem to be related to maps and arrays of the struct properties so I guess I'm missing some important steps in the decoding process.

@deankarn
Copy link

deankarn commented Jul 25, 2016

Hey @themihai

It is a good attempt, I think you just may be overcomplicating it; all of the logic already exists to parse slices and maps, what I was thinking was change this line to call setFieldByType

and the rest should handle itself, at least that's the theory ;)

UPDATE: oh and put the traverseStruct in an else{}

@deankarn
Copy link

deankarn commented Jul 26, 2016

Hey @themihai just an FYI, I've completed the Decoder portion of these changes and if all goes well will finish up making the same changes to Encoder in the morning and will then cut a new release

@themihai
Copy link
Author

Indeed, it was easier than I thought! Looking forward for the updates! With this change the encoder supports pretty much any valid data type including basic types.

deankarn pushed a commit that referenced this issue Jul 26, 2016
@deankarn
Copy link

Hey @themihai this change has been made is in Release 2.0.0

if there are any issues please don't hesitate to reopen.

@deankarn
Copy link

Hey @themihai just checking to make sure this is working out for you?

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

2 participants