mirror of
https://github.com/Syping/ragephoto-cli.git
synced 2025-11-09 13:15:17 +01:00
put JsonSerializerOptions in SerializerOptions
This commit is contained in:
parent
dccd33bcf4
commit
348945ac0c
1 changed files with 7 additions and 6 deletions
13
Json.cs
13
Json.cs
|
|
@ -1,4 +1,5 @@
|
|||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
namespace RagePhoto.Cli;
|
||||
|
||||
|
|
@ -69,9 +70,7 @@ internal class Json {
|
|||
},
|
||||
_ => throw new ArgumentException("Invalid format", nameof(format)),
|
||||
};
|
||||
return json.ToJsonString(new() {
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
});
|
||||
return json.ToJsonString(SerializerOptions);
|
||||
}
|
||||
|
||||
internal static String UpdateSign(Photo photo, String json) {
|
||||
|
|
@ -79,13 +78,15 @@ internal class Json {
|
|||
if (JsonNode.Parse(json) is not JsonObject jsonObject)
|
||||
throw new ArgumentException("Invalid json", nameof(json));
|
||||
jsonObject["sign"] = photo.Sign;
|
||||
return jsonObject.ToJsonString(new() {
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
});
|
||||
return jsonObject.ToJsonString(SerializerOptions);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Console.Error.WriteLine($"Failed to update sign: {exception.Message}");
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
internal static readonly JsonSerializerOptions SerializerOptions = new() {
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue