This did require a slight change to the RuntimeFieldAccessor to use Type.GetRuntimeProperties().Single(...) rather than Type.GetRuntimeProperty(name) to let it see the internal properties but this still doesn't quite seem to work. I end up with doubled-up field names in JsonApiSerializer.DeserializeFields().
So I've had to result to adding internal string properties called Latitude and Longitude and then having public, expression bodied properties called LatitudeDegs and LongitudeDegs that both parse their relevant string fields but this feels like a bodge on a bodge at this point and I'd prefer a cleaner solution.
I think adding something that would allow us to go .Deserialize().Custom<TIn, TOut>(func<TIn, TOut> deserializeFunc) would be nice.
Any thoughts on this or ideas for a workaround to my issue?
The API I'm working with has
Latitude
andLongitude
fields encoded as strings. Ideally, I want these on my models as doubles.So far, the best I've been able to come up with is to do:
and then have this on my class:
This did require a slight change to the
RuntimeFieldAccessor
to useType.GetRuntimeProperties().Single(...)
rather thanType.GetRuntimeProperty(name)
to let it see theinternal
properties but this still doesn't quite seem to work. I end up with doubled-up field names inJsonApiSerializer.DeserializeFields()
.So I've had to result to adding internal string properties called
Latitude
andLongitude
and then having public, expression bodied properties calledLatitudeDegs
andLongitudeDegs
that both parse their relevant string fields but this feels like a bodge on a bodge at this point and I'd prefer a cleaner solution.I think adding something that would allow us to go
.Deserialize().Custom<TIn, TOut>(func<TIn, TOut> deserializeFunc)
would be nice.Any thoughts on this or ideas for a workaround to my issue?