-
Notifications
You must be signed in to change notification settings - Fork 62
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
json: cannot unmarshal number into Go struct field Metadata.MediaContainer.Metadata.ratingCount of type string #41
Comments
The whole Changing "json: cannot unmarshal number into Go struct field Metadata.MediaContainer.Metadata.librarySectionID of type string" I change now I get "json: cannot unmarshal number into Go struct field Media.MediaContainer.Metadata.Media.id of type string" I change that to int and now I get: "json: cannot unmarshal number into Go struct field Part.MediaContainer.Metadata.Media.Part.id of type string" I change that now I get "json: cannot unmarshal number into Go struct field Media.MediaContainer.Metadata.Media.optimizedForStreaming of type bool" I change that to int and it works, but breaks In #35 I changed the following to satisfy the returned types in
Are you able to test this on your server? Maybe it's just me? Edit: |
For clarity, the following two functions (and more) share the same
|
We should try this solution first: https://stackoverflow.com/questions/49097385/how-to-decode-json-with-type-convert-from-string-to-integer-in-golang-for-non-lo. Or maybe we should come up with a custom Unmarshaler by implementing the interface I haven't had the chance to test it on my side. My PMS server version is 1.24.5.5173 by the way. |
After changing the appropriate properties to use The only one that I can't handle is
Custom Unmarshaler may be the best route for this |
I found this solution that could resolve our issue here. I may test it in the future. What should I do to reproduce the issue? |
Good find! This commit did something similar take care of it, but there are possibly some edge cases that are not well thought out with my commit. To reproduce the issue I was using the commands: Edit:
Not sure if having different media would affect the output of boolean or int on Looking forward to your thoughts or suggestions. |
I've just tested the fix. While the fix itself works for the field
I will work on a separate branch to fix those different issues. I propose to replace very float/int (and some string) fields with json.Number to avoid further issues. |
I came up with a working solution. I still have to make some test to make a PR but it fixes the aforementioned issues. Take a look at my branch |
Really great work! Looked it over and I love the naming conventions the dynamic types. I think your PR will nullify #35, so I am looking forward to that. I am curious about some of the Some Good stuff! |
No, it is a mistake on my side.
I'm still working on it and making some tests to see what's the best solution. Of course, it's way more sensible to use an integer type for |
* fixed the types for metadata json responses * added GetPlaylist() to cli * added GetPlaylist() to cli * fixed GetPlaylist() - catch non-200 status http errors * changed types on properties that are int or string * changed RatingCount per #41 * handle OptimizedForStreaming bool or int
I encountered this issue when using the function
GetPlaylist(int)
. What seems to fix it is to change the fieldRatingCount
of typeMetadata
fromstring
toint
. It appears that #35 does not bring a fix for that though.The text was updated successfully, but these errors were encountered: