I'm wondering if anyone has seen this "issue" before and potential solutions on how to correct it?
I have a specific date format (MicrosoftDateFormat) that needs to be used when talking to an SAP Gateway service for DateTime fields.
This code:
string payload = JsonConvert.SerializeObject(myObject, new JsonSerializerSettings()
{
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
});
serializes the DateTime fields into the required formats, e.g.:
"DocumentModifiedDate": "/Date(1533686400000)/"
But I then need to transform the JSON to a JToken object in order to pass it through the framework to my web service. When I transform to a JToken, the date is formatted back to the ATOM style approach:
var jot = Newtonsoft.Json.Linq.JToken.Parse(payload);
Which results in:
"DocumentModifiedDate": "2018-08-08T00:00:00Z"
I've tried using the JToken.FromObject approach:
var jot = Newtonsoft.Json.Linq.JToken.FromObject(myObject, new JsonSerializer()
{
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
});
But this doesn't seem to make use of the of serializer settings.
Hopefully someone has encountered this before and can assist.
If you can't assist here, then is there an easy way to perform that conversion in node.js because there is a chance to do it on the web server side before actually sending it off to SAP. I'm not wanting to add too much complexity to the web side of the equation so if I can do it on the app side, it'd be a lot more preferrable.