Quantcast
Channel: Json.NET
Viewing all articles
Browse latest Browse all 1767

Closed Unassigned: Issue with DateTimeOffset = Ignore. I found that default value is added with release download dll and manually compiled version is ok. [24559]

$
0
0
I tried it on Json45r11.
Source code:

```
class Program
{
static void Main(string[] args)
{
ParticipantEntity product = new ParticipantEntity();
product.Properties = new Dictionary<string, string>{{"s","d"}};
string json = JsonConvert.SerializeObject(product);
}

internal class ParticipantEntity
{
private Dictionary<string, string> _properties;

[JsonConstructor]
public ParticipantEntity()
{
}

/// <summary>
/// Gets or sets the date and time that the participant was created in the CU.
/// </summary>
[JsonProperty(PropertyName = "pa_created", DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset CreationDate { get; internal set; }

/// <summary>
/// Gets the properties of the participant.
/// </summary>
[JsonProperty(PropertyName = "pa_info")]
public Dictionary<string, string> Properties
{
get { return _properties ?? (_properties = new Dictionary<string, string>()); }
set { _properties = value; }
}
}
}
```
Result with manually compiled code:
```
{"pa_info":{"s":"d"}}
```
Result with downloaded library 4.5.11.15520 (the same is with newest version built for Net Framework 4.0):

```
{"pa_created":"0001-01-01T00:00:00+00:00","pa_info":{"s":"d"}}
```

It seems that default behavior depends on local computer locale where it was built.

PS: If it helps I added my compiled library.

Thanks for advice.
Yurii
Comments: I get {"pa_info":{"s":"d"}} with the latest offical version of json.net from NuGet

Viewing all articles
Browse latest Browse all 1767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>