void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("properties"); writer.WriteStartObject(); writer.WritePropertyName("policyAssignmentId"); writer.WriteStringValue(PolicyAssignmentId); if (Optional.IsCollectionDefined(PolicyDefinitionReferenceIds)) { writer.WritePropertyName("policyDefinitionReferenceIds"); writer.WriteStartArray(); foreach (var item in PolicyDefinitionReferenceIds) { writer.WriteStringValue(item); } writer.WriteEndArray(); } writer.WritePropertyName("exemptionCategory"); writer.WriteStringValue(ExemptionCategory.ToString()); if (Optional.IsDefined(ExpiresOn)) { writer.WritePropertyName("expiresOn"); writer.WriteStringValue(ExpiresOn.Value, "O"); } if (Optional.IsDefined(DisplayName)) { writer.WritePropertyName("displayName"); writer.WriteStringValue(DisplayName); } if (Optional.IsDefined(Description)) { writer.WritePropertyName("description"); writer.WriteStringValue(Description); } if (Optional.IsDefined(Metadata)) { writer.WritePropertyName("metadata"); #if NET6_0_OR_GREATER writer.WriteRawValue(Metadata); #else JsonSerializer.Serialize(writer, JsonDocument.Parse(Metadata.ToString()).RootElement); #endif } writer.WriteEndObject(); writer.WriteEndObject(); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("properties"); writer.WriteStartObject(); writer.WritePropertyName("policyAssignmentId"); writer.WriteStringValue(PolicyAssignmentId); if (Optional.IsCollectionDefined(PolicyDefinitionReferenceIds)) { writer.WritePropertyName("policyDefinitionReferenceIds"); writer.WriteStartArray(); foreach (var item in PolicyDefinitionReferenceIds) { writer.WriteStringValue(item); } writer.WriteEndArray(); } writer.WritePropertyName("exemptionCategory"); writer.WriteStringValue(ExemptionCategory.ToString()); if (Optional.IsDefined(ExpiresOn)) { writer.WritePropertyName("expiresOn"); writer.WriteStringValue(ExpiresOn.Value, "O"); } if (Optional.IsDefined(DisplayName)) { writer.WritePropertyName("displayName"); writer.WriteStringValue(DisplayName); } if (Optional.IsDefined(Description)) { writer.WritePropertyName("description"); writer.WriteStringValue(Description); } if (Optional.IsDefined(Metadata)) { writer.WritePropertyName("metadata"); writer.WriteObjectValue(Metadata); } writer.WriteEndObject(); writer.WriteEndObject(); }