docs
docs copied to clipboard
In the "Include Fields" sample code the "Produces output like the following example:" line is incorrect
- The initial output of Forecast1 incorrectly has the fields as lowercase; i.e., "date", when the inputted JSON text string has the fields with initial capitalization.
- When you enter these as initial capitalization, the Forecast2 sample OUTPUT changes the field names to lowercase.
- In both examples, when I run the output, the date values are switched to my local time zone (East Coast): Forecast1: "Date":"2020-09-06T11:31:01.923395**-07:00**", becomes "Date":"2020-09-06T14:31:01.923395**-04:00**", Forecast2: "Date":"2020-09-06T11:31:01.923395**-07:00**", becomes "date":"2020-09-06T14:31:01.923395**-04:00**", (though the bold text does not appear, my point is the time zone changes in both examples and the case of the field names are altered to initial lowercase in Forecast2).
It appears the sample dates were defined on the West Coast of the US. I ran the code on the East Coast of the US and the time-zone of the date was updated, reflecting a different value. Though this could easily be missed by someone on the West Coast, I think this change may be helpful to mention, even if it is by design.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 588ae32f-3429-143f-824c-5ab2d046d24a
- Version Independent ID: 002f9f2a-48d1-0671-a079-b99b9f6bab58
- Content: How to serialize and deserialize JSON using C# - .NET
- Content Source: docs/standard/serialization/system-text-json-how-to.md
- Product: dotnet-fundamentals
- GitHub Login: @tdykstra
- Microsoft Alias: tdykstra
@Loves2Code Thanks for reporting that.
- Error in the sample output -- I'm fixing it.
- The change to camel case is a result of initializing the options to web defaults -- that's unnecessary for this example, so I'm removing the web defaults.
- Inclusion of time zone in the JSON is unnecessary for this example, so I'm removing it.