Let's assume the following sample piece of code:
[<Literal>]
let jsonSample =
"""
{
"TimeInterval": {
"Start" : "2010-01-01",
"End" : "2010-01-02"
}
}
"""
type MyJson = JsonProvider<jsonSample>
The TypeProvider successfully identifies the type of fields to DateTime, however it automatically sets "DateTimeKind" field to "Local". As a result, my code becomes dependent on the machine it's running on and the timezone set in Windows settings.
When I attempt to roundtrip the following record:
{ "TimeInterval": { "Start" : "2010-01-01", "End" : "2010-01-02" } }
and my machine is set to "Europe/Bern +1", I end up serialising
{ "TimeInterval": { "Start" : "2010-01-01T00:00:00000+01:00", "End" : "2010-01-02T00:00:00000+01:00" } }
Can I change this behavior and instruct the Type Provider to leave DateTime's "Kind" field "Unspecified" ?
EDIT:
I do the roundtrip by:
let json = MyJson.Parse inFilePath
use outputStream = new StreamWriter(outFilePath, false)
outputStream.WriteLine (json.JsonValue.ToString())
json.JsonValue.ToString()