Example #1
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            ((fhirCsR4.Models.BackboneElement) this).SerializeJson(writer, options, false);

            if (Height != null)
            {
                writer.WritePropertyName("height");
                Height.SerializeJson(writer, options);
            }

            if (Width != null)
            {
                writer.WritePropertyName("width");
                Width.SerializeJson(writer, options);
            }

            if (Depth != null)
            {
                writer.WritePropertyName("depth");
                Depth.SerializeJson(writer, options);
            }

            if (Weight != null)
            {
                writer.WritePropertyName("weight");
                Weight.SerializeJson(writer, options);
            }

            if (NominalVolume != null)
            {
                writer.WritePropertyName("nominalVolume");
                NominalVolume.SerializeJson(writer, options);
            }

            if (ExternalDiameter != null)
            {
                writer.WritePropertyName("externalDiameter");
                ExternalDiameter.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Shape))
            {
                writer.WriteString("shape", (string)Shape !);
            }

            if (_Shape != null)
            {
                writer.WritePropertyName("_shape");
                _Shape.SerializeJson(writer, options);
            }

            if ((Color != null) && (Color.Count != 0))
            {
                writer.WritePropertyName("color");
                writer.WriteStartArray();

                foreach (string valColor in Color)
                {
                    writer.WriteStringValue(valColor);
                }

                writer.WriteEndArray();
            }

            if ((_Color != null) && (_Color.Count != 0))
            {
                writer.WritePropertyName("_color");
                writer.WriteStartArray();

                foreach (Element val_Color in _Color)
                {
                    val_Color.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Imprint != null) && (Imprint.Count != 0))
            {
                writer.WritePropertyName("imprint");
                writer.WriteStartArray();

                foreach (string valImprint in Imprint)
                {
                    writer.WriteStringValue(valImprint);
                }

                writer.WriteEndArray();
            }

            if ((_Imprint != null) && (_Imprint.Count != 0))
            {
                writer.WritePropertyName("_imprint");
                writer.WriteStartArray();

                foreach (Element val_Imprint in _Imprint)
                {
                    val_Imprint.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Image != null) && (Image.Count != 0))
            {
                writer.WritePropertyName("image");
                writer.WriteStartArray();

                foreach (Attachment valImage in Image)
                {
                    valImage.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Scoring != null)
            {
                writer.WritePropertyName("scoring");
                Scoring.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }