From 5385850248575dcf15634c0177137d9d77a45ff8 Mon Sep 17 00:00:00 2001 From: "David R. Williamson" Date: Tue, 18 Oct 2022 10:15:53 -0700 Subject: [PATCH] Remove ToJson() methods --- .../EdgeDeploymentSample/EdgeDeploymentSample.cs | 6 ++---- iothub/service/src/Twin/Models/Twin.cs | 10 ---------- iothub/service/src/Twin/Models/TwinCollection.cs | 10 ---------- provisioning/service/src/Twin/Twin.cs | 10 ---------- provisioning/service/src/Twin/TwinCollection.cs | 10 ---------- 5 files changed, 2 insertions(+), 44 deletions(-) diff --git a/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.cs b/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.cs index c0d1b3d4d4..d8bbdf801d 100644 --- a/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.cs +++ b/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.cs @@ -44,13 +44,11 @@ public async Task RunSampleAsync() { Console.WriteLine($"Created edge device {device.Id}"); Twin twin = await _serviceClient.Twins.GetAsync(device.Id); - Console.WriteLine($"\tTwin is {twin.ToJson()}"); + Console.WriteLine($"\tTwin is {JsonSerializer.Serialize(twin)}"); twin.Tags[conditionPropertyName] = conditionPropertyValue; await _serviceClient.Twins.UpdateAsync(device.Id, twin); - Console.WriteLine($"\tUpdated twin to {twin.ToJson()}"); - - Console.WriteLine(); + Console.WriteLine($"\tUpdated twin to {JsonSerializer.Serialize(twin)}\n"); } var baseConfiguration = new Configuration($"{ConfigurationIdPrefix}base-{Guid.NewGuid()}") diff --git a/iothub/service/src/Twin/Models/Twin.cs b/iothub/service/src/Twin/Models/Twin.cs index 8d6cb85124..d4759a15cc 100644 --- a/iothub/service/src/Twin/Models/Twin.cs +++ b/iothub/service/src/Twin/Models/Twin.cs @@ -175,16 +175,6 @@ public Twin(TwinProperties twinProperties) [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public virtual IReadOnlyList ParentScopes { get; internal set; } = new List(); - /// - /// Gets the Twin as a JSON string. - /// - /// Optional. Formatting for the output JSON string. - /// JSON string. - public string ToJson(Formatting formatting = Formatting.None) - { - return JsonConvert.SerializeObject(this, formatting); - } - /// /// For use in serialization. /// diff --git a/iothub/service/src/Twin/Models/TwinCollection.cs b/iothub/service/src/Twin/Models/TwinCollection.cs index f5f46b14b2..73bd132254 100644 --- a/iothub/service/src/Twin/Models/TwinCollection.cs +++ b/iothub/service/src/Twin/Models/TwinCollection.cs @@ -176,16 +176,6 @@ public DateTimeOffset GetLastUpdatedOnUtc() return (long?)_metadata?[LastUpdatedVersionName]; } - /// - /// Gets the properties as a JSON string. - /// - /// Optional. Formatting for the output JSON string. - /// JSON string. - public string ToJson(Formatting formatting = Formatting.None) - { - return JsonConvert.SerializeObject(JObject, formatting); - } - /// /// Determines whether the specified property is present. /// diff --git a/provisioning/service/src/Twin/Twin.cs b/provisioning/service/src/Twin/Twin.cs index 115c7d8733..7ffbcbb779 100644 --- a/provisioning/service/src/Twin/Twin.cs +++ b/provisioning/service/src/Twin/Twin.cs @@ -172,15 +172,5 @@ public Twin(TwinProperties twinProperties) /// [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public virtual IReadOnlyList ParentScopes { get; internal set; } = new List(); - - /// - /// Gets the twin as a JSON string. - /// - /// Formatting for the output JSON string. - /// JSON string - public string ToJson(Formatting formatting = Formatting.None) - { - return JsonConvert.SerializeObject(this, formatting); - } } } diff --git a/provisioning/service/src/Twin/TwinCollection.cs b/provisioning/service/src/Twin/TwinCollection.cs index ddf055dd09..1239de0293 100644 --- a/provisioning/service/src/Twin/TwinCollection.cs +++ b/provisioning/service/src/Twin/TwinCollection.cs @@ -188,16 +188,6 @@ public DateTime GetLastUpdatedOnUtc() return (long?)_metadata?[LastUpdatedVersionName]; } - /// - /// Gets the TwinProperties as a JSON string. - /// - /// Optional. Formatting for the output JSON string. - /// JSON string - public string ToJson(Formatting formatting = Formatting.None) - { - return JsonConvert.SerializeObject(JObject, formatting); - } - /// /// Determines whether the specified property is present. ///