/// <summary> /// Deserialize JSON into a FHIR Coverage#Class /// </summary> public static void DeserializeJson(this Coverage.ClassComponent 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($"Coverage.ClassComponent >>> Coverage#Class.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"Coverage.ClassComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR Coverage#Class into JSON /// </summary> public static void SerializeJson(this Coverage.ClassComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: Coverage#Class, Export: ClassComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); writer.WritePropertyName("type"); current.Type.SerializeJson(writer, options); writer.WriteString("value", current.ValueElement.Value); if (current.NameElement != null) { if (!string.IsNullOrEmpty(current.NameElement.Value)) { writer.WriteString("name", current.NameElement.Value); } if (current.NameElement.HasExtensions() || (!string.IsNullOrEmpty(current.NameElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_name", false, current.NameElement.Extension, current.NameElement.ElementId); } } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR Coverage#Class /// </summary> public static void DeserializeJsonProperty(this Coverage.ClassComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "type": current.Type = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Type).DeserializeJson(ref reader, options); break; case "value": if (reader.TokenType == JsonTokenType.Null) { current.ValueElement = new FhirString(); reader.Skip(); } else { current.ValueElement = new FhirString(reader.GetString()); } break; case "_value": if (current.ValueElement == null) { current.ValueElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.ValueElement).DeserializeJson(ref reader, options); break; case "name": if (reader.TokenType == JsonTokenType.Null) { current.NameElement = new FhirString(); reader.Skip(); } else { current.NameElement = new FhirString(reader.GetString()); } break; case "_name": if (current.NameElement == null) { current.NameElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.NameElement).DeserializeJson(ref reader, options); break; // Complex: class, Export: ClassComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }