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

More lenient unmarshal type rules #3

Closed
jpoehls opened this issue Mar 12, 2014 · 4 comments
Closed

More lenient unmarshal type rules #3

jpoehls opened this issue Mar 12, 2014 · 4 comments

Comments

@jpoehls
Copy link

jpoehls commented Mar 12, 2014

I'm playing with using this package to unmarshal plist files output by the Day One app. They are a bit quirky in that the data types in their plist file change depending on the data. So for example, in one file a value might be <integer> but in another <real>.

I tried to handle this by making my struct fields float64 thinking that the less specific integer should unmarshal into this just fine. Alas, it did not.

list: type mismatch: tried to decode integer into value of type float64

I'd rather not fall back to unmarshalling this as generic XML. Any chance there is a workaround or some change that could be made to your package to support this scenario? Open to any recommendations you have.

@DHowett
Copy link
Owner

DHowett commented Mar 12, 2014

Huh, interesting. You ought to be able to make do with interface{} for the type in question, but I realize that's non-ideal.

Internally, we support the concept of lax decoding - maybe it's useful to enable us to "lax-decode" an int as a float64?

@DHowett
Copy link
Owner

DHowett commented Mar 12, 2014

(also, thank you!)

@DHowett
Copy link
Owner

DHowett commented Mar 12, 2014

Thinking about this more, it makes sense to allow consumers to provide their own plist unmarshaling functions. I'm mulling over a core rewrite (right now, we have an intermediate format to and from which objects are marshaled/unmarshaled before they're flattened out to disk; i'd like to end that :P) that might allow me to integrate something like that.

DHowett added a commit that referenced this issue Mar 20, 2017
@DHowett
Copy link
Owner

DHowett commented Mar 20, 2017

The changes in 221fc98 should address this somewhat; you can use a custom unmarshal type.

@DHowett DHowett closed this as completed Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants