SlideShare une entreprise Scribd logo
1  sur  10
Using JSON Schema
Validator
- By Rahul Kumar
Prerequisites
JSON
Reference : https://tools.ietf.org/html/rfc7159
JSON Schema
Reference : http://json-schema.org/documentation.html
JSON Schema Validator
JSON schema validator is used to validate JSON data against a JSON schema.
The JSON Schema validator evaluates JSON payloads at runtime and verifies
that they match a referenced JSON schema. You can match against schemas
that exist in a local file or in an external URI. If the validation fails, an exception
is raised with feedback about what went wrong and a reference to the original
invalid payload. The JSON Schema Validator supports schema drafts of
version 4 and older.
Accepted Payload Types
java.lang.String, java.io.Reader, InputStream, byte[],
com.fasterxml.jackson.databind.JsonNode, org.mule.module.json.JsonData
If the payload type is none of the above, then the validator attempts to
transform the payload into a usable type, in the following order:
org.mule.module.json.JsonData
com.fasterxml.jackson.databind.JsonNode
java.lang.String
ConfigurationFollowing are the properties on general tab:
Display Name – The display name of the connector used for display purposes in
Mule flow.
Schema Location – Location of the schema. It may be a web URL, file system
URL etc.
Dereferencing - Draft v4 defines two dereferencing modes, canonical (default)
and inline. This attribute is ignored if validating a v3 draft.
Schema redirects - Schema Validator supports referencing URIs to external
schemas, and because one schema might reference another, the validator
also supports URI redirection, so that a reference to another schema doesn’t
Schema Redirects
In this example, any links to the external address
http://my.site/schemas/fstab.json will redirect to the internal address
resource:/org/mule/json/examples/fstab.json.
Validation Behavior
If the validation is successful, then control is passed to the next processor in
the chain. Otherwise a JsonSchemaValidationException is thrown
containing validation feedback on the message. This exception contains a
message with a detailed explanation of what went wrong, and a property
called invalidJson in which the invalid payload is available on its String
representation.
Precaution
For performing validation the validator consumes a streaming resource
(InputStream, Reader, etc), so the message payload is altered to the fully
consumed JSON.
So you may pass a payload of type java.io.InputStream or a java.io.Reader
but you may get back a String
Flow
Thank You !!

Contenu connexe

Tendances

Tendances (20)

Collection aggregator
Collection aggregatorCollection aggregator
Collection aggregator
 
Basic example using choice component
Basic example using choice componentBasic example using choice component
Basic example using choice component
 
How to use splitter component
How to use splitter componentHow to use splitter component
How to use splitter component
 
Mule message processor or routers
Mule message processor or routersMule message processor or routers
Mule message processor or routers
 
Routing in mule
Routing in muleRouting in mule
Routing in mule
 
Defining global exception strategies
Defining global exception strategiesDefining global exception strategies
Defining global exception strategies
 
Wildcard Filter
Wildcard FilterWildcard Filter
Wildcard Filter
 
Oracle startup phases and concepts
Oracle startup phases and conceptsOracle startup phases and concepts
Oracle startup phases and concepts
 
Unidirectional data flow
Unidirectional data flowUnidirectional data flow
Unidirectional data flow
 
How to use processor chain
How to use processor chainHow to use processor chain
How to use processor chain
 
How to use parse template
How to use parse templateHow to use parse template
How to use parse template
 
Data Mapper
Data MapperData Mapper
Data Mapper
 
How to get http query parameters in mule
How to get http query parameters in muleHow to get http query parameters in mule
How to get http query parameters in mule
 
Howtouseforeachcomponent
HowtouseforeachcomponentHowtouseforeachcomponent
Howtouseforeachcomponent
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
 
Mule security - spring security manager
Mule  security - spring security managerMule  security - spring security manager
Mule security - spring security manager
 
Splitter
SplitterSplitter
Splitter
 
Until Successful Component
Until Successful ComponentUntil Successful Component
Until Successful Component
 
Bealls florida automation overview
Bealls florida automation overviewBealls florida automation overview
Bealls florida automation overview
 
Database component in mule
Database component in muleDatabase component in mule
Database component in mule
 

En vedette

JSON Referencing and Schema
JSON Referencing and SchemaJSON Referencing and Schema
JSON Referencing and Schema
kriszyp
 
JSON Schema: Your API's Secret Weapon
JSON Schema: Your API's Secret WeaponJSON Schema: Your API's Secret Weapon
JSON Schema: Your API's Secret Weapon
Pete Gamache
 

En vedette (20)

Validating a json in mule
Validating a json in muleValidating a json in mule
Validating a json in mule
 
JSON Referencing and Schema
JSON Referencing and SchemaJSON Referencing and Schema
JSON Referencing and Schema
 
XML's validation - XML Schema
XML's validation - XML SchemaXML's validation - XML Schema
XML's validation - XML Schema
 
JSON Schema: Your API's Secret Weapon
JSON Schema: Your API's Secret WeaponJSON Schema: Your API's Secret Weapon
JSON Schema: Your API's Secret Weapon
 
Weblogic Administration Managed Server migration
Weblogic Administration Managed Server migrationWeblogic Administration Managed Server migration
Weblogic Administration Managed Server migration
 
4 xml namespaces and xml schema
4   xml namespaces and xml schema4   xml namespaces and xml schema
4 xml namespaces and xml schema
 
Oracle BPM 11g Lesson 2
Oracle BPM 11g Lesson 2Oracle BPM 11g Lesson 2
Oracle BPM 11g Lesson 2
 
Oracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPSOracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPS
 
Enterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12cEnterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12c
 
Oracle WebLogic 11g Topology
Oracle WebLogic 11g TopologyOracle WebLogic 11g Topology
Oracle WebLogic 11g Topology
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning Tutorial
 
Oracle BPM 11g Lesson 1
Oracle BPM 11g Lesson 1Oracle BPM 11g Lesson 1
Oracle BPM 11g Lesson 1
 
Oracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSMOracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSM
 
Oracle OSB Tutorial 3
Oracle OSB Tutorial 3Oracle OSB Tutorial 3
Oracle OSB Tutorial 3
 
Talking Services with Oracle ADF and Oracle SOA Suite
Talking Services with Oracle ADF and Oracle SOA SuiteTalking Services with Oracle ADF and Oracle SOA Suite
Talking Services with Oracle ADF and Oracle SOA Suite
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Osb student guide
Osb student guideOsb student guide
Osb student guide
 
Oracle OSB Tutorial 2
Oracle OSB Tutorial 2Oracle OSB Tutorial 2
Oracle OSB Tutorial 2
 
Oracle EMC 12C Grand Tour
Oracle EMC 12C Grand TourOracle EMC 12C Grand Tour
Oracle EMC 12C Grand Tour
 
SOA OSB suite cluster installation
SOA OSB suite cluster installationSOA OSB suite cluster installation
SOA OSB suite cluster installation
 

Similaire à Using JSON Schema Validator

Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
DEEPAK KHETAWAT
 
Java Web services
Java Web servicesJava Web services
Java Web services
Sujit Kumar
 

Similaire à Using JSON Schema Validator (20)

Validate json schema component
Validate json schema componentValidate json schema component
Validate json schema component
 
6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework
 
Ppt on web development and this has all details
Ppt on web development and this has all detailsPpt on web development and this has all details
Ppt on web development and this has all details
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
Soa 31 jax ws server side development architecture
Soa 31 jax ws server side development architectureSoa 31 jax ws server side development architecture
Soa 31 jax ws server side development architecture
 
WIT UNIT-5.pdf
WIT UNIT-5.pdfWIT UNIT-5.pdf
WIT UNIT-5.pdf
 
Railsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUDRailsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUD
 
Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3
 
Frisby Api automation
Frisby Api automationFrisby Api automation
Frisby Api automation
 
Spring REST Request Validation
Spring REST Request ValidationSpring REST Request Validation
Spring REST Request Validation
 
#speakgeek - Angular JS
#speakgeek - Angular JS#speakgeek - Angular JS
#speakgeek - Angular JS
 
SCDJWS 5. JAX-WS
SCDJWS 5. JAX-WSSCDJWS 5. JAX-WS
SCDJWS 5. JAX-WS
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Web services
Java Web servicesJava Web services
Java Web services
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI Tool
 
web programming
web programmingweb programming
web programming
 
Rest web service
Rest web serviceRest web service
Rest web service
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4
 

Plus de Rahul Kumar

Plus de Rahul Kumar (20)

Combine collections transformer
Combine collections transformerCombine collections transformer
Combine collections transformer
 
Creating global functions
Creating global functionsCreating global functions
Creating global functions
 
Creating custom object store
Creating custom object storeCreating custom object store
Creating custom object store
 
Using parse template component
Using parse template componentUsing parse template component
Using parse template component
 
Using groovy component
Using groovy componentUsing groovy component
Using groovy component
 
Using expression component
Using expression componentUsing expression component
Using expression component
 
Creating custom transformer
Creating custom transformerCreating custom transformer
Creating custom transformer
 
Creating custom aggregation strategy
Creating custom aggregation strategyCreating custom aggregation strategy
Creating custom aggregation strategy
 
Creating custom aggregator
Creating custom aggregatorCreating custom aggregator
Creating custom aggregator
 
Byte array to hex string transformer
Byte array to hex string transformerByte array to hex string transformer
Byte array to hex string transformer
 
Creating custom filter
Creating custom filterCreating custom filter
Creating custom filter
 
Hex string to byte array transformer
Hex string to byte array transformerHex string to byte array transformer
Hex string to byte array transformer
 
XML to DOM Transformer
XML to DOM TransformerXML to DOM Transformer
XML to DOM Transformer
 
Dom to xml transformer
Dom to xml transformerDom to xml transformer
Dom to xml transformer
 
Object to input stream transformer
Object to input stream transformerObject to input stream transformer
Object to input stream transformer
 
Byte array to object transformer
Byte array to object transformerByte array to object transformer
Byte array to object transformer
 
Byte array to string transformer
Byte array to string transformerByte array to string transformer
Byte array to string transformer
 
Object to string transformer
Object to string transformerObject to string transformer
Object to string transformer
 
Csv to json transform in simple steps
Csv to json transform in simple stepsCsv to json transform in simple steps
Csv to json transform in simple steps
 
Using scatter gather
Using scatter gatherUsing scatter gather
Using scatter gather
 

Dernier

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Dernier (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

Using JSON Schema Validator

  • 2. Prerequisites JSON Reference : https://tools.ietf.org/html/rfc7159 JSON Schema Reference : http://json-schema.org/documentation.html
  • 3. JSON Schema Validator JSON schema validator is used to validate JSON data against a JSON schema. The JSON Schema validator evaluates JSON payloads at runtime and verifies that they match a referenced JSON schema. You can match against schemas that exist in a local file or in an external URI. If the validation fails, an exception is raised with feedback about what went wrong and a reference to the original invalid payload. The JSON Schema Validator supports schema drafts of version 4 and older.
  • 4. Accepted Payload Types java.lang.String, java.io.Reader, InputStream, byte[], com.fasterxml.jackson.databind.JsonNode, org.mule.module.json.JsonData If the payload type is none of the above, then the validator attempts to transform the payload into a usable type, in the following order: org.mule.module.json.JsonData com.fasterxml.jackson.databind.JsonNode java.lang.String
  • 5. ConfigurationFollowing are the properties on general tab: Display Name – The display name of the connector used for display purposes in Mule flow. Schema Location – Location of the schema. It may be a web URL, file system URL etc. Dereferencing - Draft v4 defines two dereferencing modes, canonical (default) and inline. This attribute is ignored if validating a v3 draft. Schema redirects - Schema Validator supports referencing URIs to external schemas, and because one schema might reference another, the validator also supports URI redirection, so that a reference to another schema doesn’t
  • 6. Schema Redirects In this example, any links to the external address http://my.site/schemas/fstab.json will redirect to the internal address resource:/org/mule/json/examples/fstab.json.
  • 7. Validation Behavior If the validation is successful, then control is passed to the next processor in the chain. Otherwise a JsonSchemaValidationException is thrown containing validation feedback on the message. This exception contains a message with a detailed explanation of what went wrong, and a property called invalidJson in which the invalid payload is available on its String representation.
  • 8. Precaution For performing validation the validator consumes a streaming resource (InputStream, Reader, etc), so the message payload is altered to the fully consumed JSON. So you may pass a payload of type java.io.InputStream or a java.io.Reader but you may get back a String