Fixed null-Errors in json
This commit is contained in:
parent
9a01db710b
commit
9eb53bb53a
@ -62,17 +62,25 @@ public class MangaDex : Connector
|
|||||||
if(tagObject!["attributes"]!["name"]!.AsObject().ContainsKey("en"))
|
if(tagObject!["attributes"]!["name"]!.AsObject().ContainsKey("en"))
|
||||||
tags.Add(tagObject!["attributes"]!["name"]!["en"]!.GetValue<string>());
|
tags.Add(tagObject!["attributes"]!["name"]!["en"]!.GetValue<string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArray relationships = manga["relationships"]!.AsArray();
|
|
||||||
string poster = relationships.FirstOrDefault(relationship => relationship["type"].GetValue<string>() == "cover_art")["id"].GetValue<string>();
|
|
||||||
|
|
||||||
JsonObject linksObject = attributes["links"]!.AsObject();
|
string? poster = null;
|
||||||
string[,] links = new string[linksObject.Count, 2];
|
if (manga.ContainsKey("relationships") && manga["relationships"] is not null)
|
||||||
int linkIndex = 0;
|
|
||||||
foreach (string key in ((IDictionary<string, JsonNode?>)linksObject).Keys)
|
|
||||||
{
|
{
|
||||||
links[linkIndex, 0] = key;
|
JsonArray relationships = manga["relationships"]!.AsArray();
|
||||||
links[linkIndex++, 1] = linksObject[key]!.GetValue<string>();
|
poster = relationships.FirstOrDefault(relationship => relationship!["type"]!.GetValue<string>() == "cover_art")!["id"]!.GetValue<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
string[,]? links = null;
|
||||||
|
if (attributes.ContainsKey("links") && attributes["links"] is not null)
|
||||||
|
{
|
||||||
|
JsonObject linksObject = attributes["links"]!.AsObject();
|
||||||
|
links = new string[linksObject.Count, 2];
|
||||||
|
int linkIndex = 0;
|
||||||
|
foreach (string key in ((IDictionary<string, JsonNode?>)linksObject).Keys)
|
||||||
|
{
|
||||||
|
links[linkIndex, 0] = key;
|
||||||
|
links[linkIndex++, 1] = linksObject[key]!.GetValue<string>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int? year = attributes.ContainsKey("year") && attributes["year"] is not null
|
int? year = attributes.ContainsKey("year") && attributes["year"] is not null
|
||||||
|
@ -6,8 +6,8 @@ public struct Publication
|
|||||||
public string[,] altTitles { get; }
|
public string[,] altTitles { get; }
|
||||||
public string? description { get; }
|
public string? description { get; }
|
||||||
public string[] tags { get; }
|
public string[] tags { get; }
|
||||||
public string posterUrl { get; } //maybe there is a better way?
|
public string? posterUrl { get; } //maybe there is a better way?
|
||||||
public string[,] links { get; }
|
public string[,]? links { get; }
|
||||||
public int? year { get; }
|
public int? year { get; }
|
||||||
public string? originalLanguage { get; }
|
public string? originalLanguage { get; }
|
||||||
public string status { get; }
|
public string status { get; }
|
||||||
@ -15,7 +15,7 @@ public struct Publication
|
|||||||
public Connector connector { get; }
|
public Connector connector { get; }
|
||||||
public string downloadUrl { get; }
|
public string downloadUrl { get; }
|
||||||
|
|
||||||
public Publication(string sortName, string? description, string[,] altTitles, string[] tags, string posterUrl, string[,] links, int? year, string? originalLanguage, string status, Connector connector, string downloadUrl)
|
public Publication(string sortName, string? description, string[,] altTitles, string[] tags, string? posterUrl, string[,]? links, int? year, string? originalLanguage, string status, Connector connector, string downloadUrl)
|
||||||
{
|
{
|
||||||
this.sortName = sortName;
|
this.sortName = sortName;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
Loading…
Reference in New Issue
Block a user