@@ -29,28 +29,6 @@ public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOp
2929 }
3030 }
3131
32- /// <summary>
33- /// Custom JSON converter that handles both string and numeric IDs, converting them to long
34- /// </summary>
35- public class FlexibleLongConverter : JsonConverter < long >
36- {
37- public override long Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
38- {
39- return reader . TokenType switch
40- {
41- JsonTokenType . Number => reader . GetInt64 ( ) ,
42- JsonTokenType . String => long . TryParse ( reader . GetString ( ) , out long result ) ? result :
43- throw new JsonException ( $ "Cannot convert string '{ reader . GetString ( ) } ' to long") ,
44- _ => throw new JsonException ( $ "Cannot convert token type { reader . TokenType } to long")
45- } ;
46- }
47-
48- public override void Write ( Utf8JsonWriter writer , long value , JsonSerializerOptions options )
49- {
50- writer . WriteNumberValue ( value ) ;
51- }
52- }
53-
5432 /// <summary>
5533 /// Custom JSON converter for flexible float handling
5634 /// </summary>
@@ -242,7 +220,7 @@ public CountryResponse() : this(false) { }
242220 public record LucidaInfo (
243221 [ property: JsonPropertyName ( "success" ) ] bool Success ,
244222 [ property: JsonPropertyName ( "type" ) ] string Type = "" ,
245- [ property: JsonPropertyName ( "id" ) , JsonConverter ( typeof ( FlexibleLongConverter ) ) ] long Id = 0 ,
223+ [ property: JsonPropertyName ( "id" ) , JsonConverter ( typeof ( FlexibleStringConverter ) ) ] string Id = "" ,
246224 [ property: JsonPropertyName ( "url" ) ] string Url = "" ,
247225 [ property: JsonPropertyName ( "title" ) ] string Title = "" ,
248226 [ property: JsonPropertyName ( "durationMs" ) ] long DurationMs = 0 ,
@@ -305,23 +283,21 @@ public record LucidaArtworkInfo(
305283 /// Album reference within track info
306284 /// </summary>
307285 public record LucidaAlbumRef (
308- [ property: JsonPropertyName ( "id" ) , JsonConverter ( typeof ( FlexibleLongConverter ) ) ] long Id ,
286+ [ property: JsonPropertyName ( "id" ) , JsonConverter ( typeof ( FlexibleStringConverter ) ) ] string Id = "" ,
309287 [ property: JsonPropertyName ( "url" ) ] string Url = "" ,
310288 [ property: JsonPropertyName ( "title" ) ] string Title = "" ,
311289 [ property: JsonPropertyName ( "releaseDate" ) ] string ? ReleaseDate = null )
312290 {
313291 [ JsonPropertyName ( "coverArtwork" ) ]
314292 public LucidaArtworkInfo [ ] CoverArtwork { get ; init ; } = Array . Empty < LucidaArtworkInfo > ( ) ;
315-
316- public LucidaAlbumRef ( ) : this ( 0 ) { }
317293 } ;
318294
319295 /// <summary>
320296 /// Track info within album
321297 /// </summary>
322298 public record LucidaTrackInfo (
323299 [ property: JsonPropertyName ( "url" ) ] string Url = "" ,
324- [ property: JsonPropertyName ( "id" ) , JsonConverter ( typeof ( FlexibleLongConverter ) ) ] long Id = 0 ,
300+ [ property: JsonPropertyName ( "id" ) , JsonConverter ( typeof ( FlexibleStringConverter ) ) ] string Id = "" ,
325301 [ property: JsonPropertyName ( "title" ) ] string Title = "" ,
326302 [ property: JsonPropertyName ( "durationMs" ) ] long DurationMs = 0 ,
327303 [ property: JsonPropertyName ( "isrc" ) ] string ? Isrc = null ,
0 commit comments