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