You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a System.Text.Json JsonObject as the TemplateContext then it is not possible to directly use filters like time_zone or date on string properties in the source json as the result is always nil.
Stepping through in the debugger it can be seen that in this case the individual JsonElements for the properties are being wrapped in a FluidValue of type FluidValues.Object. However FluidValueExtensions.TryGetDateTimeInput does not handle this case and returns false.
As a workaround it is possible to call another string filter first, e.g. strip, which internally calls FluidValue.ToStringValue() which unwraps the JsonElement string value and provides it as a FluidValues.String to subsequent filters which then succeed.
I believe the straightforward fix to this issue would be either to extend FluidValueExtensions.TryGetDateTimeInput to add a call to FluidValue.ToStringValue() on the fallback paths before returning false, or to explicitly handle the JsonElement case in the same object type switch statement used for DateTime & DateTimeOffset objects if JsonElement is also considered a Well Known Type for Fluid.
The text was updated successfully, but these errors were encountered:
When using a System.Text.Json JsonObject as the TemplateContext then it is not possible to directly use filters like time_zone or date on string properties in the source json as the result is always nil.
Stepping through in the debugger it can be seen that in this case the individual JsonElements for the properties are being wrapped in a FluidValue of type FluidValues.Object. However FluidValueExtensions.TryGetDateTimeInput does not handle this case and returns false.
As a workaround it is possible to call another string filter first, e.g. strip, which internally calls FluidValue.ToStringValue() which unwraps the JsonElement string value and provides it as a FluidValues.String to subsequent filters which then succeed.
I believe the straightforward fix to this issue would be either to extend FluidValueExtensions.TryGetDateTimeInput to add a call to FluidValue.ToStringValue() on the fallback paths before returning false, or to explicitly handle the JsonElement case in the same object type switch statement used for DateTime & DateTimeOffset objects if JsonElement is also considered a Well Known Type for Fluid.
The text was updated successfully, but these errors were encountered: