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.

Provide an @Required annotation to indicate that a field must be present

See original GitHub issue
See discussion at http://groups.google.com/group/google-
gson/browse_thread/thread/6cfdcc56742357da

During deserialization, Gson should throw a JsonParseException if it finds 
that a field marked with @Required is not present. 

During serialization, Gson should always write out a field marked @Required 
even if it is null. 

Original issue reported on code.google.com by inder123 on 17 Oct 2008 at 10:31

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:296
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

69reactions
tir38commented, Jul 28, 2016

Please use this thumbs up button to show your support. Every time someone replies with +1 we all get a (useless) email. screen shot 2016-07-28 at 12 03 59 pm

44reactions
arbiturcommented, Feb 22, 2019

Still waiting for this feature… I want my Gson deserializing to throw an exception when a JSON doesnt have a parameter which my object do have and is either marked as @Required or not marked as @Optional. This is a big dealbreaker that Gson doesn’t have this feature…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring - Required Annotation - GeeksforGeeks
This annotation indicates that the affected bean property must be populated at configuration time: either through an explicit property value ...
Read more >
Data Annotations for validation, at least one required field?
DataAnnotations namespace, set it up to validate that at least one of the fields in the search is not null or empty? i.e...
Read more >
Require a value in a field - Microsoft Support
In the Field Properties pane, on the General tab, set the Required property to Yes. The Required Field Property. Note: If you set...
Read more >
AIP-203: Field behavior documentation
The use of REQUIRED indicates that the field must be present (and set to a non-empty value) on the request or resource. A...
Read more >
4.11 Annotation-based configuration - Spring
This annotation simply indicates that the affected bean property must be ... is to treat annotated methods, constructors, and fields as indicating required...
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