Closed plustik closed 4 months ago
Would just using #[serde(default)]
also work? https://serde.rs/attr-default.html
Would just using
#[serde(default)]
also work? https://serde.rs/attr-default.html
Reading through the issue seems like it wouldn't work: https://github.com/ramsayleung/rspotify/issues/459#issuecomment-2025391563
Would just using
#[serde(default)]
also work? https://serde.rs/attr-default.html
#[serde(default)]
would not work. This is also discussed here. The workaround given there is almost the same as the one I copied from here.
Thanks for your contribution.
Description
Adjust the derived implementation of
Deserialize
forSimplifiedPlaylist
. Instead of returning an error when deserializing the valuenull
for the fieldimages
, this value is deserialized to an emptyVec
. This is necessary, because the Spotify-API is returningnull
instead of an empty array for this field in some instances.Motivation and Context
This fixes the problem described in https://github.com/ramsayleung/rspotify/issues/459. The Spotify-API is returning
null
instead of an empty array for theimages
-field in some instances.Dependencies
None
Type of change
Please delete options that are not relevant.
How has this been tested?
The change was tested by using the patched version of rspotify in this project.
Is this change properly documented?
I don't think this needs to be documented. The change won't affect the behavior of rspotify when the Spotify-API returns
images: []
. When the Spotify-API returnsimages: null
current_user_playlists
wasn't usable prior to this change. In this case the PR implements the expected behavior.