Skip to content

Commit

Permalink
fix: enhance FieldValue with null handling and type-safe access (#1)
Browse files Browse the repository at this point in the history
- Implement NullValueHandling.Ignore for JSON serialization
- Change Value property from dynamic to object for clarity
- Add GetValue<T>() method for type-safe value retrieval
  • Loading branch information
ducksoop committed Jan 23, 2024
1 parent c908e87 commit 609d91d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions QuickbaseNet/Models/FieldValue.cs
Original file line number Diff line number Diff line change
@@ -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<T>()
{
return Value == null ? default : (T)Convert.ChangeType(Value, typeof(T));
}
}
}

0 comments on commit 609d91d

Please sign in to comment.