Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
db7bdad
initial draft
tdykstra Nov 27, 2019
c9e7a21
fix links
tdykstra Dec 12, 2019
88cd245
fix link
tdykstra Dec 13, 2019
0f60978
corrections
tdykstra Dec 13, 2019
3c634dc
add new doc to toc
tdykstra Dec 13, 2019
d994f56
add'l notes from ahson email
tdykstra Dec 13, 2019
6d4216c
fix issue numbers
tdykstra Dec 13, 2019
2594e49
comment out roadmap link
tdykstra Dec 13, 2019
823b581
incorporate info from roadmap
tdykstra Dec 15, 2019
7dd85d6
more info from roadmap
tdykstra Dec 15, 2019
3a2ab3d
address thraka feedback
tdykstra Dec 17, 2019
c546273
Newtonsoft --> Json.NET
tdykstra Dec 17, 2019
07cc159
omit 'the current release of'
tdykstra Dec 17, 2019
20f1095
omit 'by design'
tdykstra Dec 17, 2019
41019bc
link to exact hash instead of branch
tdykstra Dec 17, 2019
0665118
Json.NET --> Newtonsoft.Json
tdykstra Dec 17, 2019
7243deb
scrub additional resources sections
tdykstra Dec 17, 2019
163ed4e
rearrange several h2 sections
tdykstra Dec 17, 2019
b5bd3e7
add (marshal/unmarshal) to headings
tdykstra Dec 19, 2019
7771245
update dates
tdykstra Dec 20, 2019
a1eae47
ahson feedback, restore code to converters doc
tdykstra Dec 24, 2019
b023d84
move 3 converters back to converter doc
tdykstra Dec 24, 2019
55d99cc
additional note from comments in 36639
tdykstra Dec 24, 2019
a78c5ac
minor clarification
tdykstra Dec 26, 2019
9c331ff
remove links to issues
tdykstra Dec 27, 2019
618aca8
add links to s.t.j.serialization
tdykstra Dec 27, 2019
84a65bc
remove extraneous words
tdykstra Dec 27, 2019
e4a27a1
remove extraneous words
tdykstra Dec 27, 2019
6b279eb
4.6.1 --> 4.7.2
tdykstra Dec 27, 2019
2feef06
Update docs/standard/serialization/system-text-json-converters-how-to.md
tdykstra Dec 27, 2019
99619d1
ahson feedback section 1
tdykstra Dec 27, 2019
ec3d07c
fix h2->h3, tweak heading text
tdykstra Dec 27, 2019
1919f9d
layomi feedback
tdykstra Dec 27, 2019
0f9a494
reapply change lost earlier
tdykstra Dec 27, 2019
16b73b3
remove dbnull comments
tdykstra Dec 28, 2019
4618b0c
Apply suggestions from code review
tdykstra Dec 31, 2019
1bcb4f3
Apply suggestion from code review
tdykstra Dec 31, 2019
66dbd62
ahson feedback
tdykstra Dec 31, 2019
805f425
Merge branch 'jnmigrate' of https://github.com/tdykstra/dotnet-docs i…
tdykstra Dec 31, 2019
6fc6377
make registration links more specific
tdykstra Dec 31, 2019
57fb760
add converters api link
tdykstra Jan 1, 2020
35434dd
Apply suggestions from code review
tdykstra Jan 1, 2020
93d7564
add note to null-to-nonnullable section
tdykstra Jan 1, 2020
2610c4a
Update docs/standard/serialization/system-text-json-migrate-from-newt…
tdykstra Jan 1, 2020
957f976
Apply suggestions from code review
tdykstra Jan 1, 2020
9fc486a
fix link
tdykstra Jan 1, 2020
bc30ca2
acrolinx and feedback
tdykstra Jan 1, 2020
9a057bb
add workaround notes
tdykstra Jan 1, 2020
93194b2
first occurrrences of STJ --> xref link
tdykstra Jan 6, 2020
2273cf4
more api ref links
tdykstra Jan 6, 2020
1c34eb5
Merge branch 'master' into jnmigrate
tdykstra Jan 6, 2020
0890e2e
strings in quotes, nonstring values, polymorphism
tdykstra Jan 7, 2020
5a0b857
corrections to polymorphic sections
tdykstra Jan 7, 2020
b721d7b
address feedback
tdykstra Jan 7, 2020
f6b0a55
more feedback
tdykstra Jan 7, 2020
26930e8
minor wording change
tdykstra Jan 7, 2020
b68ba5e
misc feedback
tdykstra Jan 8, 2020
80ed897
misc feedback
tdykstra Jan 8, 2020
c2191e6
revise polymorphic interface example
tdykstra Jan 8, 2020
43a657a
misc feedback
tdykstra Jan 8, 2020
7b53d91
fix links
tdykstra Jan 8, 2020
fd05648
standardize links to source code
tdykstra Jan 8, 2020
303d8e5
shorten valuetextequals example
tdykstra Jan 8, 2020
63e02ab
misc feedback
tdykstra Jan 8, 2020
65be137
misc feedback
tdykstra Jan 9, 2020
72a8a34
valuetuple
tdykstra Jan 10, 2020
50b3574
invitation to share workaround code
tdykstra Jan 10, 2020
fd61261
feedback
tdykstra Jan 10, 2020
942e7c2
proofread pass
tdykstra Jan 10, 2020
f6d6623
update ms.date
tdykstra Jan 10, 2020
2fa28ee
tools --> APIs
tdykstra Jan 10, 2020
27d4fd4
feedback
tdykstra Jan 10, 2020
55ee7b7
immutablestack
tdykstra Jan 10, 2020
b3eb4f4
clarify when to clone
tdykstra Jan 10, 2020
2470d9e
revert change already made by 16615
tdykstra Jan 11, 2020
30277d7
Update docs/standard/serialization/system-text-json-migrate-from-newt…
tdykstra Jan 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add converters api link
  • Loading branch information
tdykstra committed Jan 1, 2020
commit 57fb760362abdcdf9b93a6f3ac4407112e9fb683
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ The following scenarios aren't supported by built-in functionality, but sample c

[!code-csharp[](~/samples/snippets/core/system-text-json/csharp/LongToStringConverter.cs)]

Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-property) on individual `long` properties or by [adding the converter to the `Converters` collection](system-text-json-converters-how-to.md#registration-sample---converters-collection).
Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-property) on individual `long` properties or by [adding the converter](system-text-json-converters-how-to.md#registration-sample---converters-collection) to the <xref:System.Text.Json.JsonSerializerOptions.Converters> collection.

### Dictionary with non-string key

Expand Down Expand Up @@ -133,7 +133,7 @@ To make deserialization fail if no `Date` property is in the JSON, implement a c

[!code-csharp[](~/samples/snippets/core/system-text-json/csharp/WeatherForecastRequiredPropertyConverter.cs)]

Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-type) on the POCO class or by [adding the converter to the `Converters` collection](system-text-json-converters-how-to.md#registration-sample---converters-collection).
Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-type) on the POCO class or by [adding the converter](system-text-json-converters-how-to.md#registration-sample---converters-collection) to the <xref:System.Text.Json.JsonSerializerOptions.Converters> collection.

If you follow this pattern, don't pass in the options object when recursively calling `Serialize` or `Deserialize`. The options object contains the `Converters` collection. If you pass it in to `Serialize` or `Deserialize`, the custom converter calls into itself, making an infinite loop that results in a stack overflow exception. If the default options are not feasible, create a new instance of the options with the settings that you need. This approach will be slow since each new instance caches independently.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach will be slow since each new instance caches independently.

@steveharter, how can we make the workaround work and not be slow?


Expand All @@ -154,7 +154,7 @@ Another workaround is to make a converter for the type, such as the following ex

[!code-csharp[](~/samples/snippets/core/system-text-json/csharp/DateTimeOffsetNullHandlingConverter.cs)]

Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-property) on the property or by [adding the converter to the `Converters` collection](system-text-json-converters-how-to.md#registration-sample---converters-collection).
Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-property) on the property or by [adding the converter](system-text-json-converters-how-to.md#registration-sample---converters-collection) to the <xref:System.Text.Json.JsonSerializerOptions.Converters> collection.

### Deserialize to immutable classes and structs

Expand All @@ -168,7 +168,7 @@ And here's a converter that serializes and deserializes this struct:

[!code-csharp[](~/samples/snippets/core/system-text-json/csharp/ImmutablePointConverter.cs)]

Register this custom converter by [adding the converter to the `Converters` collection](system-text-json-converters-how-to.md#registration-sample---converters-collection).
Register this custom converter by [adding the converter](system-text-json-converters-how-to.md#registration-sample---converters-collection) to the <xref:System.Text.Json.JsonSerializerOptions.Converters> collection.

For an example of a similar converter that handles open generic properties, see the [built-in converter for key-value pairs](https://github.com/dotnet/runtime/blob/master/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/JsonValueConverterKeyValuePair.cs).

Expand Down Expand Up @@ -204,7 +204,7 @@ For that functionality, you can write a custom converter. Here's a sample POCO a

The converter causes the `Summary` property to be omitted from serialization if its value is null, an empty string, or "N/A".

Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-type) on the class or by [adding the converter to the `Converters` collection](system-text-json-converters-how-to.md#registration-sample---converters-collection).
Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-type) on the class or by [adding the converter](system-text-json-converters-how-to.md#registration-sample---converters-collection) to the <xref:System.Text.Json.JsonSerializerOptions.Converters> collection.

This approach requires additional logic if:

Expand All @@ -224,7 +224,7 @@ In `System.Text.Json`, you can simulate callbacks by writing a custom converter.

[!code-csharp[](~/samples/snippets/core/system-text-json/csharp/WeatherForecastCallbacksConverter.cs)]

Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-type) on the class or by [adding the converter to the `Converters` collection](system-text-json-converters-how-to.md#registration-sample---converters-collection).
Register this custom converter by [using an attribute](system-text-json-converters-how-to.md#registration-sample---jsonconverter-on-a-type) on the class or by [adding the converter](system-text-json-converters-how-to.md#registration-sample---converters-collection) to the <xref:System.Text.Json.JsonSerializerOptions.Converters> collection.

If you use a custom converter that follows this example:

Expand Down