question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FeatureRequest: Deserialize null to empty collection

See original GitHub issue

He there,

Hi there, what to you think about adding the possibility to map null values to empty collections?

If I have a object

// pseudo code
class Person {
  String name
  List<String> nicknames = new ArrayList()
}

and a json

{
  "name": "jackson",
  "nicknames": null
}

it would be cool to get an instance where the nicknames collection is empty instead of null

  assert person.nicknames.size() == 0

Best regards, Leif

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:39
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

8reactions
saden1commented, May 8, 2014

+1 …nulls are really evil!

6reactions
tadhgpearsoncommented, Jan 13, 2015

+1 Would the best way to do it be a DeserializationFeature? For example DeserializationFeature.READ_NULL_ARRAY_AS_EMPTY_COLLECTION ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jackson deserializer - change null collection to empty one
So few questions: Is there some jackson property that changes null to empty collection during deserialization? If no for the first point -...
Read more >
How to remove null/empty JSON nodes from a request body?
The script converts the body to a JSON object and then walks through it recursively and removes fields that have null, empty array...
Read more >
Set deserialized grid state in OnStateInit handler cause error ...
Reason: FilterDescriptors property MemberType = null. Note: Method TelerikGrid.SetState() works correctly.
Read more >
Something like Serializable that allows null? - Unity Forum
// Values are populated upon deserialization... Thanks... public class ItemBundleProperties. {. public string ...
Read more >
Describing Parameters - Swagger
Query parameters can be primitive values, arrays and objects. OpenAPI 3.0 provides several ways to serialize objects and arrays in the query string....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found