commercetools / commercetools-dotnet-core-sdk-v2

https://commercetools.github.io/commercetools-dotnet-core-sdk-v2/docs/html/index.html
Apache License 2.0
16 stars 11 forks source link

CustomField Deserialization missing DateTime handling #184

Closed csi-lund closed 1 year ago

csi-lund commented 1 year ago

When deserializing custom fields registered as CustomFieldDateTimeType they are deserialized to string.

The current FieldMapperTypeRetriever doesnt seem to handle the datetime, dates and so the FieldContainerConverter returns string values that must be converted manually

I believe we are missing logic as per the java SDK v2 where we check the that the string values are a datetime, time, date and convert it as such. CustomFieldDeserializer

To Reproduce Create a custom field as CustomFieldDateTimeType get the field from commercetools view the ProjectApiRoot

Expected behavior A datetime deserialized value

Screenshots/Code snippet If applicable, add screenshots or code samples to help explain your problem.

Stack information (please complete the following information):

jenschude commented 1 year ago

We learned the hard way in the v1 .NET and the Java SDKs that it was not the best idea to automatically deserialize to dates and times as there are use cases which store string data in resembling a date or time format. Therefor we decided to not include some format detection.

We could add some extension function which will try to parse a string to date or time to simplify the dealing with these kind of fields