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