Some checks failed
		
		
	
	Docs CI / lint-and-preview (push) Has been cancelled
				
			Build Test Deploy / build-test (push) Has been cancelled
				
			Build Test Deploy / authority-container (push) Has been cancelled
				
			Build Test Deploy / docs (push) Has been cancelled
				
			Build Test Deploy / deploy (push) Has been cancelled
				
			
		
			
				
	
	
		
			27 lines
		
	
	
		
			827 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			827 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Text.Json;
 | |
| using System.Text.Json.Serialization;
 | |
| 
 | |
| namespace StellaOps.Scanner.Core.Contracts;
 | |
| 
 | |
| internal sealed class ScanJobIdJsonConverter : JsonConverter<ScanJobId>
 | |
| {
 | |
|     public override ScanJobId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 | |
|     {
 | |
|         if (reader.TokenType != JsonTokenType.String)
 | |
|         {
 | |
|             throw new JsonException("Expected scan job identifier to be a string.");
 | |
|         }
 | |
| 
 | |
|         var value = reader.GetString();
 | |
|         if (!ScanJobId.TryParse(value, out var id))
 | |
|         {
 | |
|             throw new JsonException("Invalid scan job identifier.");
 | |
|         }
 | |
| 
 | |
|         return id;
 | |
|     }
 | |
| 
 | |
|     public override void Write(Utf8JsonWriter writer, ScanJobId value, JsonSerializerOptions options)
 | |
|         => writer.WriteStringValue(value.ToString());
 | |
| }
 |