/// <summary> /// Deserialize JSON into a FHIR RelatedPerson#Communication /// </summary> public static void DeserializeJson(this RelatedPerson.CommunicationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options) { string propertyName; while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return; } if (reader.TokenType == JsonTokenType.PropertyName) { propertyName = reader.GetString(); if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug) { Console.WriteLine($"RelatedPerson.CommunicationComponent >>> RelatedPerson#Communication.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"RelatedPerson.CommunicationComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR RelatedPerson#Communication /// </summary> public static void DeserializeJsonProperty(this RelatedPerson.CommunicationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "language": current.Language = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Language).DeserializeJson(ref reader, options); break; case "preferred": if (reader.TokenType == JsonTokenType.Null) { current.PreferredElement = new FhirBoolean(); reader.Skip(); } else { current.PreferredElement = new FhirBoolean(reader.GetBoolean()); } break; case "_preferred": if (current.PreferredElement == null) { current.PreferredElement = new FhirBoolean(); } ((Hl7.Fhir.Model.Element)current.PreferredElement).DeserializeJson(ref reader, options); break; // Complex: communication, Export: CommunicationComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR RelatedPerson#Communication into JSON /// </summary> public static void SerializeJson(this RelatedPerson.CommunicationComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: RelatedPerson#Communication, Export: CommunicationComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); writer.WritePropertyName("language"); current.Language.SerializeJson(writer, options); if (current.PreferredElement != null) { if (current.PreferredElement.Value != null) { writer.WriteBoolean("preferred", (bool)current.PreferredElement.Value); } if (current.PreferredElement.HasExtensions() || (!string.IsNullOrEmpty(current.PreferredElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_preferred", false, current.PreferredElement.Extension, current.PreferredElement.ElementId); } } if (includeStartObject) { writer.WriteEndObject(); } }