|
Bugzilla – Full Text Bug Listing |
| Summary: | DataContractJsonSerializer doesn't deserialize non-null values for nullable members properly | ||
|---|---|---|---|
| Product: | [Mono] Mono: Class Libraries | Reporter: | Forgotten User ZsvJbCwNxG <forgotten_ZsvJbCwNxG> |
| Component: | WCF | Assignee: | Atsushi Enomoto <atsushieno> |
| Status: | NEW --- | QA Contact: | Mono Bugs <mono-bugs> |
| Severity: | Normal | ||
| Priority: | P5 - None | CC: | forgotten_ZsvJbCwNxG |
| Version: | 2.8.x | ||
| Target Milestone: | --- | ||
| Hardware: | i686 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
| Attachments: | test.cs | ||
The issue is in DataContractJsonSerializer, which is not in System.Web.Extensions but in System.ServiceModel.Web (.NET 3.5) or System.Runtime.Serialization (.NET 4.0) Also, the results are different using the attached test case to those described in the report. parm_id is assigned 0 (wrong) but val is assigned null (correct). Created attachment 406709 [details]
test.cs
Thanks for detailing/clarifying the test case. Chris |
Description of Problem: The DataContractJsonSerializer is filling nullable value types with 0 instead of the true value even when a value is provided. I would expect the nullable value type to default to null if not provided within the stream else be set to value provided by the stream. Steps to reproduce the problem: 1. [DataContract] public class c { public c() { } [DataMember] public int? parm_id { get; set; } [DataMember] public decimal? val { get; set; } } 2. string js = "{\"parm_id\":2}"; Use DataContractJsonSerializer to fill an instance with js. Actual Results: parm_id contains 0. val contains 0 Expected Results: parm_id should contain 2. val should contain null. How often does this happen? Everytime. Additional Information: Native windows returns expected results.