-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add specification for ReferenceHandling #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
85259e9
Add specification for ReferenceHandling
jozkee f5f85c1
Address more feedback, corrected types, and included table of contents
jozkee e12a8f6
Add missing access modifiers to class properties
jozkee 24c6d17
Apply suggestions from code review
jozkee 6b4a91b
Apply more suggestions from code review
jozkee 095d5a9
Add PR suggestions.
jozkee bc2701c
Apply even more suggestions from code review
jozkee cc1ac66
Add missing semi colons on samples and standardize error messages on …
jozkee 95d2636
Address changes discussed on API review
jozkee 94021e1
Add note to describe unsupported round-tripping capability on JsonExt…
jozkee c23959d
Replace i.e. for e.g. where meant to quote an example.
jozkee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Apply even more suggestions from code review
Co-Authored-By: Ahson Khan <[email protected]>
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |||||
| - [In depth](#in-depth) | ||||||
| - [Compatibility](#compatibility) | ||||||
| - [Examples](#examples) | ||||||
| - [Using Default on Deserialize](#using-default-on-deserialize) | ||||||
| - [Using Default on Serialize](#using-default-on-serialize) | ||||||
| - [Using Ignore on Serialize](#using-ignore-on-serialize) | ||||||
| - [Using Preserve on Serialize](#using-preserve-on-serialize) | ||||||
|
|
@@ -381,7 +382,7 @@ Similar: https://www.npmjs.com/package/json-cyclic | |||||
| ## flatted (JavaScript module) (probably not worth it) | ||||||
| https://github.com/WebReflection/flatted | ||||||
|
|
||||||
| * While stringifying, all Objects, including Arrays and strings, are flattened out and replaced with unique index. | ||||||
| * While stringifying, all Objects, including Arrays and strings, are flattened out and replaced with a unique index. | ||||||
| * Once parsed, all indexes will be replaced through the flattened collection. | ||||||
| * It has 23M downloads per month. | ||||||
| * Every single value (primitive and complex) is preserved. | ||||||
|
|
@@ -643,13 +644,13 @@ public static void TestDictionary_Collision() | |||||
| ## Immutable types | ||||||
| Since these types are created with the help of an internal converter, and they are not parsed until the entire block of JSON finishes; nested reference to these types is impossible to identify, unless you re-scan the resulting object, which is too expensive. | ||||||
ahsonkhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| With that said, the deserializer will throw when it reads `$id` on any of these types; but regardless of that, when writing those types, they are going to be preserved as any other collection type (`{ "$id": "1", "$values": [...] }`) since those types can still being parsed into a collection type that it is supported. | ||||||
| With that said, the deserializer will throw when it reads `$id` on any of these types. When serializing (i.e. writing) those types, however, they are going to be preserved as any other collection type (`{ "$id": "1", "$values": [...] }`) since those types can still be parsed into a collection type that is supported. | ||||||
|
|
||||||
| Note: By the same principle, `Newtonsoft.Json` does not support parsing JSON arrays into immutables as well. | ||||||
| Note 2: When using immutable types and `ReferenceHandling.Preserve`, you will not be able to generate payloads that are capables of round-tripping. | ||||||
|
|
||||||
| * **Immutable types**: i.e: `ImmutableList` and `ImmutableDictionary` | ||||||
|
||||||
| * **Immutable types**: i.e: `ImmutableList` and `ImmutableDictionary` | |
| * **Immutable types**: e.g. `ImmutableList` and `ImmutableDictionary` |
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always though i.e. stands for "in example".
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.