From 28344d861d6e539d482ac9743788951191b965fe Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 28 Oct 2017 19:41:25 -0400 Subject: [PATCH] Clarify handling of non-object omitted fields (#1169) While deserializing, a missing entry in JSON results in setting the corresponding field in the object to its default value: null for object types, zero for numeric types, and false for booleans. --- UserGuide.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/UserGuide.md b/UserGuide.md index 67a7c22a..4feaf11c 100644 --- a/UserGuide.md +++ b/UserGuide.md @@ -144,14 +144,14 @@ BagOfPrimitives obj2 = gson.fromJson(json, BagOfPrimitives.class); #### **Finer Points with Objects** -* It is perfectly fine (and recommended) to use private fields +* It is perfectly fine (and recommended) to use private fields. * There is no need to use any annotations to indicate a field is to be included for serialization and deserialization. All fields in the current class (and from all super classes) are included by default. * If a field is marked transient, (by default) it is ignored and not included in the JSON serialization or deserialization. -* This implementation handles nulls correctly -* While serializing, a null field is skipped from the output -* While deserializing, a missing entry in JSON results in setting the corresponding field in the object to null -* If a field is _synthetic_, it is ignored and not included in JSON serialization or deserialization -* Fields corresponding to the outer classes in inner classes, anonymous classes, and local classes are ignored and not included in serialization or deserialization +* This implementation handles nulls correctly. +* While serializing, a null field is omitted from the output. +* While deserializing, a missing entry in JSON results in setting the corresponding field in the object to its default value: null for object types, zero for numeric types, and false for booleans. +* If a field is _synthetic_, it is ignored and not included in JSON serialization or deserialization. +* Fields corresponding to the outer classes in inner classes, anonymous classes, and local classes are ignored and not included in serialization or deserialization. ### Nested Classes (including Inner Classes)