Recent Posts
Archives

Posts Tagged ‘StephaneRondal’

PostHeaderIcon [DevoxxBE2012] Why & How: JSON Validation with JSON Schema and Jackson

Stephane Rondal, co-founder of Arexo Consulting and a Java EE expert, introduced JSON Schema validation using Jackson. Stephane, with decades in software architecture, explained JSON’s ubiquity in web 2.0, mobile, and RESTful services, yet noted lacking structural validation compared to XML.

He advocated JSON Schema for defining constraints like types, formats, and cardinalities, ensuring data integrity. Benefits include self-documenting APIs, early error detection, and improved interoperability.

Drawbacks: added complexity, performance overhead, and evolving standards (draft 3 then, now higher).

Stephane demonstrated schema creation for documents with headers and items, specifying required fields and enums.

Using Jackson’s JsonSchema module, he validated instances, catching issues like type mismatches.

Implementing Validation in Practice

Stephane integrated validation post-parsing, using ObjectMapper and JsonNode for tree traversal. Tests showed valid/invalid responses, with errors reported clearly.

He recommended the Jackson-based validator for its maintenance and spec adherence.

Links: