snipt

Ctrl+h for KB shortcuts

Text only

Jackson - property missing on deserialization

1
2
3
What happens if I annotate a constructor parameter using @JsonProperty but the Json doesn't specify that property. What value does the constructor get?

How do I differentiate between a property having a null value versus a property that is not present in the JSON?

Description

http://stackoverflow.com/questions/8320993/jackson-what-happens-if-a-property-is-missing
https://snipt.net/embed/0f216c5a41202aba5c3d114d750026e4/
/raw/0f216c5a41202aba5c3d114d750026e4/
0f216c5a41202aba5c3d114d750026e4
text
Text only
6
2019-08-22T17:08:42
True
False
False
Oct 28, 2015 at 03:07 PM
/api/public/snipt/141994/
jackson-propery-missing-on-deserialization
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>What happens if I annotate a constructor parameter using @JsonProperty but the Json doesn&#39;t specify that property. What value does the constructor get? </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>How do I differentiate between a property having a null value versus a property that is not present in the JSON? </span></pre></div> </td></tr></table>
jackson, java
1
2
3
4
5
6
7
8
--- 
+++ 
@@ -2,4 +2,4 @@
 
 How do I differentiate between a property having a null value versus a property that is not present in the JSON?
 
-http://stackoverflow.com/questions/8320993/jackson-what-happens-if-a-property-is-missing
+
1
2
3
4
5
6
7
8
--- 
+++ 
@@ -1,3 +1,5 @@
 What happens if I annotate a constructor parameter using @JsonProperty but the Json doesn't specify that property. What value does the constructor get?
 
 How do I differentiate between a property having a null value versus a property that is not present in the JSON?
+
+http://stackoverflow.com/questions/8320993/jackson-what-happens-if-a-property-is-missing
1
2
3
4
5
6
--- 
+++ 
@@ -0,0 +1,3 @@
+What happens if I annotate a constructor parameter using @JsonProperty but the Json doesn't specify that property. What value does the constructor get?
+
+How do I differentiate between a property having a null value versus a property that is not present in the JSON?