From 609d91d439eb911dd4c0371ecb891ae77a445a96 Mon Sep 17 00:00:00 2001 From: ducksoop Date: Mon, 22 Jan 2024 22:24:44 -0600 Subject: [PATCH] fix: enhance FieldValue with null handling and type-safe access (#1) - Implement NullValueHandling.Ignore for JSON serialization - Change Value property from dynamic to object for clarity - Add GetValue() method for type-safe value retrieval --- QuickbaseNet/Models/FieldValue.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/QuickbaseNet/Models/FieldValue.cs b/QuickbaseNet/Models/FieldValue.cs index 9788243..8a2654b 100644 --- a/QuickbaseNet/Models/FieldValue.cs +++ b/QuickbaseNet/Models/FieldValue.cs @@ -1,10 +1,16 @@ using Newtonsoft.Json; +using System; namespace QuickbaseNet.Models { public class FieldValue { - [JsonProperty("value")] - public dynamic Value { get; set; } + [JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)] + public object Value { get; set; } + + public T GetValue() + { + return Value == null ? default : (T)Convert.ChangeType(Value, typeof(T)); + } } } \ No newline at end of file