2
0

Fix Settings not returning as JSON

This commit is contained in:
Glax 2024-08-26 12:59:19 +02:00
parent 7b91bb699f
commit 6d723b6355
2 changed files with 5 additions and 3 deletions

View File

@ -198,7 +198,7 @@ public class Server : GlobalBase
SendResponse(HttpStatusCode.OK, response, _parent.jobBoss.jobs.Where(jjob => jjob is DownloadNewChapters).OrderBy(jjob => ((DownloadNewChapters)jjob).manga.sortName));
break;
case "Settings":
SendResponse(HttpStatusCode.OK, response, TrangaSettings.Serialize());
SendResponse(HttpStatusCode.OK, response, TrangaSettings.AsJObject());
break;
case "Settings/userAgent":
SendResponse(HttpStatusCode.OK, response, TrangaSettings.userAgent);

View File

@ -151,7 +151,7 @@ public static class TrangaSettings
File.WriteAllText(settingsFilePath, Serialize());
}
public static string Serialize()
public static JObject AsJObject()
{
JObject jobj = new JObject();
jobj.Add("downloadLocation", JToken.FromObject(TrangaSettings.downloadLocation));
@ -161,9 +161,11 @@ public static class TrangaSettings
jobj.Add("aprilFoolsMode", JToken.FromObject(TrangaSettings.aprilFoolsMode));
jobj.Add("version", JToken.FromObject(TrangaSettings.version));
jobj.Add("requestLimits", JToken.FromObject(TrangaSettings.requestLimits));
return jobj.ToString();
return jobj;
}
public static string Serialize() => AsJObject().ToString();
public static void Deserialize(string serialized)
{
JObject jobj = JObject.Parse(serialized);