Skip to content

Comments

Fixed issues #926, and #928.#942

Merged
JohnnyCrazy merged 2 commits intoJohnnyCrazy:masterfrom
Lewis-Fam:m_dev
Feb 10, 2024
Merged

Fixed issues #926, and #928.#942
JohnnyCrazy merged 2 commits intoJohnnyCrazy:masterfrom
Lewis-Fam:m_dev

Conversation

@Lewis-Fam
Copy link
Contributor

Added a double to int Json Converter and added attributes to impacted properties.

Added JsonConverter attributes to properties.
@munissor
Copy link

FWIW, I like this approach, will fix the serialization issue in a non-breaking way. The public API will keep integers until we can figure out if the change from Spotify is intentional or not.

@Lewis-Fam
Copy link
Contributor Author

There are a few ways to handle the failing check.

Either, update the attribute tag to:
[JsonConverter(typeof(DoubleToIntConverter), NullValueHandling.Ignore)]

or

Change the converter.

I believe that the latter would a better appraoch. The simplest implementation would be:

public class DoubleToIntConverter : JsonConverter<int>
{
  public override void WriteJson(JsonWriter? writer, int value, JsonSerializer serializer)
  {
    writer?.WriteValue(value);
  }

  public override int ReadJson(JsonReader? reader, Type objectType, int existingValue, bool hasExistingValue,
    JsonSerializer serializer)
  {
    return reader != null ? Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture) : 0;
  }
}

@JohnnyCrazy
Copy link
Owner

AFAIK, DurationMs is not a double/int problem. It's encoded in an object, see discussion in #926

@Lewis-Fam
Copy link
Contributor Author

Lewis-Fam commented Jan 26, 2024 via email

@JohnnyCrazy
Copy link
Owner

Do you have local tracks in the playlist? I think that's the only case where we see objects in the durationMs field.

@narutoshocker
Copy link

Hello,

Is this going to be merged soon or do we still have lingering issues?

@JohnnyCrazy
Copy link
Owner

Will be merged soonish, couple of days max, need to do some additional testing.

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

Successfully merging this pull request may close these issues.

4 participants