/// <summary> /// Deserialize JSON into a FHIR Account#Guarantor /// </summary> public static void DeserializeJson(this Account.GuarantorComponent 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($"Account.GuarantorComponent >>> Account#Guarantor.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"Account.GuarantorComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR Account#Guarantor into JSON /// </summary> public static void SerializeJson(this Account.GuarantorComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: Account#Guarantor, Export: GuarantorComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); writer.WritePropertyName("party"); current.Party.SerializeJson(writer, options); if (current.OnHoldElement != null) { if (current.OnHoldElement.Value != null) { writer.WriteBoolean("onHold", (bool)current.OnHoldElement.Value); } if (current.OnHoldElement.HasExtensions() || (!string.IsNullOrEmpty(current.OnHoldElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_onHold", false, current.OnHoldElement.Extension, current.OnHoldElement.ElementId); } } if (current.Period != null) { writer.WritePropertyName("period"); current.Period.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR Account#Guarantor /// </summary> public static void DeserializeJsonProperty(this Account.GuarantorComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "party": current.Party = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Party).DeserializeJson(ref reader, options); break; case "onHold": if (reader.TokenType == JsonTokenType.Null) { current.OnHoldElement = new FhirBoolean(); reader.Skip(); } else { current.OnHoldElement = new FhirBoolean(reader.GetBoolean()); } break; case "_onHold": if (current.OnHoldElement == null) { current.OnHoldElement = new FhirBoolean(); } ((Hl7.Fhir.Model.Element)current.OnHoldElement).DeserializeJson(ref reader, options); break; case "period": current.Period = new Hl7.Fhir.Model.Period(); ((Hl7.Fhir.Model.Period)current.Period).DeserializeJson(ref reader, options); break; // Complex: guarantor, Export: GuarantorComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }