void IJsonSerializable.WriteProperties(Utf8JsonWriter json)
        {
            if (KeyMaterial != null)
            {
                json.WriteStartObject(s_keyPropertyNameBytes);

                KeyMaterial.WriteProperties(json);

                json.WriteEndObject();
            }

            Properties.WriteAttributes(json);

            if (Properties._tags != null && Properties._tags.Count > 0)
            {
                json.WriteStartObject(s_tagsPropertyNameBytes);

                foreach (KeyValuePair <string, string> kvp in Properties._tags)
                {
                    json.WriteString(kvp.Key, kvp.Value);
                }

                json.WriteEndObject();
            }

            if (Hsm.HasValue)
            {
                json.WriteBoolean(s_hsmPropertyNameBytes, Hsm.Value);
            }
        }
        internal override void WriteProperties(Utf8JsonWriter json)
        {
            if (KeyMaterial != null)
            {
                json.WriteStartObject(KeyPropertyNameBytes);
                KeyMaterial.WriteProperties(json);
                json.WriteEndObject();
            }

            if (Enabled.HasValue || NotBefore.HasValue || Expires.HasValue)
            {
                json.WriteStartObject(AttributesPropertyNameBytes);

                if (Enabled.HasValue)
                {
                    json.WriteBoolean(EnabledPropertyNameBytes, Enabled.Value);
                }

                if (NotBefore.HasValue)
                {
                    json.WriteNumber(NotBeforePropertyNameBytes, NotBefore.Value.ToUnixTimeSeconds());
                }

                if (Expires.HasValue)
                {
                    json.WriteNumber(ExpiresPropertyNameBytes, Expires.Value.ToUnixTimeSeconds());
                }

                json.WriteEndObject();
            }

            if (Tags != null && Tags.Count > 0)
            {
                json.WriteStartObject(TagsPropertyNameBytes);

                foreach (KeyValuePair <string, string> kvp in Tags)
                {
                    json.WriteString(kvp.Key, kvp.Value);
                }

                json.WriteEndObject();
            }

            if (Hsm.HasValue)
            {
                json.WriteBoolean(HsmPropertyNameBytes, Hsm.Value);
            }
        }