SlideShare a Scribd company logo
Writing Domain Specific Languages with JSON Schema
Writing Domain Specific Languages
with JSON Schema
Yos Riady
yos.io
bit.ly/2JbMTrn
Weak types in JSON
What is JSON Schema?
Introduction Schema Uses DSL Conclusion
JSON Schema use
cases
Summary and further
learning
Writing a DSL with
JSON Schema
Writing Domain Specific Languages with JSON Schema
JSON is weakly typed
{
“userName”: “Yos”,
“favouriteNumber”: 42,
“interests”: [“programming”, “swimming”]
}
Writing Domain Specific Languages with JSON Schema
message Person {
required string user_name = 1
optional int64 favourite_number = 2
repeated string interests = 3
}
Protocol Buffers are strongly typed
Writing Domain Specific Languages with JSON Schema
How can we validate
JSON data with types?
Enter JSON Schema
{
“userName”: { “type”: “string” },
“favouriteNumber”: { “type”: “integer” },
“interests”: { “type”: “array”, “items”: { “type”: “string”} }
}
JSON Schema helps you validate
JSON data.
jsonschemalint.com
JSON Schema 101
{
"type": "string"
}
Valid Invalid
“foo” 123
false
JSON Schema Basic Types
● string
● Numeric types
● object
● array
● boolean
● null
{
"type": "object",
"properties": {
"userName": {
"type": "string"
}
},
"required": ["userName"],
"additionalProperties": false,
}
JSON Schema 101 Valid Invalid
{
“userName”:
“foo”
}
{
“userName”: 1
}
{
“name”: “foo”
}
{}
JSON Schema 101
Invalid Validation Message
{
“userName”: 1
}
Field .userName should be a string
{
“name”: “foo”
}
Should NOT have additional properties
{} Should have required property ‘userName’
Additional JSON Schema Validations
{
"type": "number",
"minimum": 0,
"maximum": 100,
"exclusiveMaximum": true
}
{
"type": "string",
"pattern": "^(([0-9]{3}))?[0-9]{3}-[0-9]{4}$"
}
Combining JSON Schemas
● AnyOf
● AllOf
● OneOf
● not
{
"anyOf": [
{ "type": "string" },
{ "type": "number" }
]
}
Structuring Complex Schemas
{
"definitions": {
"person": { ... }
},
"type": "object",
"properties": {
"user": { "$ref": "#/definitions/person" }
}
}
Writing Domain Specific Languages with JSON Schema
jsonschemalint.com
Use Cases for JSON Schema
● Message / data validation
○ Object Relational Mappers (ORMs)
● Schemaless objects in Web Applications
● Content Management in Headless CMSes
● Writing Specification Languages
○ OpenAPI / Swagger
○ AWS States Language
○ WAML
Hapi.js object validation
Dynamic forms
Content Modeling in Headless CMSes
Content Modeling in Headless CMSes
Writing Specification Languages
Weak types in JSON
What is JSON Schema?
Introduction Schema Uses DSL Conclusion
JSON Schema use
cases
Summary and further
learning
Writing a DSL with
JSON Schema
Writing a DSL with JSON Schema
Domain Specific Languages
● Computer language specialized to a particular application domain
○ In contrast to General Purpose Languages (GPLs)
OpenAPI / Swagger
Web Automation Markup Language (waml.io)
waml.io/editor
Writing a DSL with JSON Schema
"waml": {
"description": "WAML Specification semantic version number.",
"type": "string",
"pattern": "^([0-9]{1,}.[0-9]{1,}.[0-9]{1,})$",
"enum": ["0.1.0"]
}
Writing a DSL with JSON Schema
"steps": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/Step"
}
}
Writing a DSL with JSON Schema
"Step": {
"type": "object",
"description": "A step represents a single user interaction.",
"oneOf": [
{
"$ref": "#/definitions/VisitStep"
},
{
"$ref": "#/definitions/ClickStep"
}
]
}
"ClickStep": {
"type": "object",
"properties": {
"click": {
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"selector": { "type": "string" },
"index": { "type": "integer", "minimum": 0 }
}
}
]
},
},
}
github.com/waml-lang/waml
Weak types in JSON
What is JSON Schema?
Introduction Schema Uses DSL Conclusion
JSON Schema use
cases
Summary and further
learning
Writing a DSL with
JSON Schema
● JSON is weakly typed
● JSON Schema
○ What is JSON Schema?
○ JSON validation with JSON Schema
○ Use cases
● Domain Specific Languages
○ What are DSLs?
○ Writing a DSL with JSON Schema
In Closing
Writing Domain Specific Languages with JSON Schema
Writing Domain Specific Languages
with JSON Schema
Yos Riady
yos.io
bit.ly/2JbMTrn
Q&A

More Related Content

PPTX
API as-a-Product with Azure API Management (APIM)
Bishoy Demian
 
PDF
An Introduction of Node Package Manager (NPM)
iFour Technolab Pvt. Ltd.
 
PPTX
Spring Security 3
Jason Ferguson
 
PPTX
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
DevDay Da Nang
 
PDF
Java Collection Interview Questions [Updated]
SoniaMathias2
 
DOCX
Aem Training Tutorials for Beginners
Shrinivas AEM Online Training
 
PDF
Complete MVC on NodeJS
Hüseyin BABAL
 
API as-a-Product with Azure API Management (APIM)
Bishoy Demian
 
An Introduction of Node Package Manager (NPM)
iFour Technolab Pvt. Ltd.
 
Spring Security 3
Jason Ferguson
 
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
DevDay Da Nang
 
Java Collection Interview Questions [Updated]
SoniaMathias2
 
Aem Training Tutorials for Beginners
Shrinivas AEM Online Training
 
Complete MVC on NodeJS
Hüseyin BABAL
 

What's hot (20)

PDF
AndroidMakers2023.pdf
Confetti3
 
PPT
Css
Manav Prasad
 
PPTX
Understanding JWT Exploitation
AkshaeyBhosale
 
PDF
Designing APIs with OpenAPI Spec
Adam Paxton
 
ODP
Microservices with Apache Camel
Claus Ibsen
 
PPTX
Introduction to angular with a simple but complete project
Jadson Santos
 
PPTX
Clean Code II - Dependency Injection
Theo Jungeblut
 
PPTX
Typescript overview
Thanvilahari
 
PPTX
AWS SQS SNS
Durgesh Vaishnav
 
PPT
Tomcat
Venkat Pinagadi
 
PDF
Introduction to the Dart language
Jana Moudrá
 
PPTX
Integrating Splunk into your Spring Applications
Damien Dallimore
 
PPTX
WebAssembly WASM Introduction Presentation
Brad Beiermann
 
PDF
WebAssembly Fundamentals
Knoldus Inc.
 
PDF
How to create a User Defined Policy with IBM APIc (v10)
Shiu-Fun Poon
 
PDF
Domain Driven Design
Young-Ho Cho
 
PPTX
Kotlin Multiplatform
Kevin Galligan
 
PPTX
Introducing Swagger
Tony Tam
 
PPTX
Protocol Buffers
Software Infrastructure
 
ODP
Kong API Gateway
Chris Mague
 
AndroidMakers2023.pdf
Confetti3
 
Understanding JWT Exploitation
AkshaeyBhosale
 
Designing APIs with OpenAPI Spec
Adam Paxton
 
Microservices with Apache Camel
Claus Ibsen
 
Introduction to angular with a simple but complete project
Jadson Santos
 
Clean Code II - Dependency Injection
Theo Jungeblut
 
Typescript overview
Thanvilahari
 
AWS SQS SNS
Durgesh Vaishnav
 
Introduction to the Dart language
Jana Moudrá
 
Integrating Splunk into your Spring Applications
Damien Dallimore
 
WebAssembly WASM Introduction Presentation
Brad Beiermann
 
WebAssembly Fundamentals
Knoldus Inc.
 
How to create a User Defined Policy with IBM APIc (v10)
Shiu-Fun Poon
 
Domain Driven Design
Young-Ho Cho
 
Kotlin Multiplatform
Kevin Galligan
 
Introducing Swagger
Tony Tam
 
Protocol Buffers
Software Infrastructure
 
Kong API Gateway
Chris Mague
 
Ad

Similar to Writing Domain Specific Languages with JSON Schema (20)

PDF
Json
soumya
 
PDF
Hands on JSON
Octavian Nadolu
 
PPT
json.ppt download for free for college project
AmitSharma397241
 
PDF
Json at work overview and ecosystem-v2.0
Boulder Java User's Group
 
KEY
Devoxx - JSON Validation using JSON Schema and Jackson
Stephane Rondal
 
PPTX
Introduction to JavaScript Object Notation(JSON)
gaikwaddavid2022
 
PDF
Basics of JSON (JavaScript Object Notation) with examples
Sanjeev Kumar Jaiswal
 
PPTX
MongoDB 3.0
Victoria Malaya
 
PPTX
Google Protocol Buffers
Sergey Podolsky
 
PDF
JSONSchema with golang
Suraj Deshmukh
 
PPTX
Java script and json
Islam Abdelzaher
 
PPTX
Intro to JSON
Mark Daniel Dacer
 
PPTX
Screaming fast json parsing on Android
Karthik Ramgopal
 
PPTX
LU 1.3. JSON & XML.pptx about how they work and introduction
niyigenagilbert6
 
PDF
YAML crash COURSE how to write yaml file for adding configuring details
NishanthaBulumulla1
 
PDF
Json tutorial, a beguiner guide
Rafael Montesinos Muñoz
 
PPTX
JSON Support in Salesforce - winter 12
Jitendra Zaa
 
PDF
Apache AVRO (Boston HUG, Jan 19, 2010)
Cloudera, Inc.
 
PDF
Apache Drill @ PJUG, Jan 15, 2013
Gera Shegalov
 
PDF
Apache big data 2016 - Speaking the language of Big Data
techmaddy
 
Json
soumya
 
Hands on JSON
Octavian Nadolu
 
json.ppt download for free for college project
AmitSharma397241
 
Json at work overview and ecosystem-v2.0
Boulder Java User's Group
 
Devoxx - JSON Validation using JSON Schema and Jackson
Stephane Rondal
 
Introduction to JavaScript Object Notation(JSON)
gaikwaddavid2022
 
Basics of JSON (JavaScript Object Notation) with examples
Sanjeev Kumar Jaiswal
 
MongoDB 3.0
Victoria Malaya
 
Google Protocol Buffers
Sergey Podolsky
 
JSONSchema with golang
Suraj Deshmukh
 
Java script and json
Islam Abdelzaher
 
Intro to JSON
Mark Daniel Dacer
 
Screaming fast json parsing on Android
Karthik Ramgopal
 
LU 1.3. JSON & XML.pptx about how they work and introduction
niyigenagilbert6
 
YAML crash COURSE how to write yaml file for adding configuring details
NishanthaBulumulla1
 
Json tutorial, a beguiner guide
Rafael Montesinos Muñoz
 
JSON Support in Salesforce - winter 12
Jitendra Zaa
 
Apache AVRO (Boston HUG, Jan 19, 2010)
Cloudera, Inc.
 
Apache Drill @ PJUG, Jan 15, 2013
Gera Shegalov
 
Apache big data 2016 - Speaking the language of Big Data
techmaddy
 
Ad

More from Yos Riady (10)

PDF
Brief introduction to Serverless (2018)
Yos Riady
 
PDF
Type Checking in Javascript with Flow
Yos Riady
 
PDF
Schema-First API Design
Yos Riady
 
PDF
GraphQL in an Age of REST
Yos Riady
 
PDF
Python List Comprehensions
Yos Riady
 
PDF
Ruby on Rails Workshop
Yos Riady
 
PDF
Online Payments and You
Yos Riady
 
PDF
Entity Component Systems
Yos Riady
 
PDF
Introduction to React
Yos Riady
 
PPTX
Intro to Web Map APIs
Yos Riady
 
Brief introduction to Serverless (2018)
Yos Riady
 
Type Checking in Javascript with Flow
Yos Riady
 
Schema-First API Design
Yos Riady
 
GraphQL in an Age of REST
Yos Riady
 
Python List Comprehensions
Yos Riady
 
Ruby on Rails Workshop
Yos Riady
 
Online Payments and You
Yos Riady
 
Entity Component Systems
Yos Riady
 
Introduction to React
Yos Riady
 
Intro to Web Map APIs
Yos Riady
 

Recently uploaded (20)

PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
PPTX
TestNG for Java Testing and Automation testing
ssuser0213cb
 
PDF
Community & News Update Q2 Meet Up 2025
VictoriaMetrics
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPT
Order to Cash Lifecycle Overview R12 .ppt
nbvreddy229
 
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
RanuFajar1
 
PDF
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PPTX
EU POPs Limits & Digital Product Passports Compliance Strategy 2025.pptx
Certivo Inc
 
PDF
Become an Agentblazer Champion Challenge
Dele Amefo
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
DOCX
The Future of Smart Factories Why Embedded Analytics Leads the Way
Varsha Nayak
 
PDF
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
PDF
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
TestNG for Java Testing and Automation testing
ssuser0213cb
 
Community & News Update Q2 Meet Up 2025
VictoriaMetrics
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Order to Cash Lifecycle Overview R12 .ppt
nbvreddy229
 
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
Materi_Pemrograman_Komputer-Looping.pptx
RanuFajar1
 
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
EU POPs Limits & Digital Product Passports Compliance Strategy 2025.pptx
Certivo Inc
 
Become an Agentblazer Champion Challenge
Dele Amefo
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
oapresentation.pptx
mehatdhavalrajubhai
 
The Future of Smart Factories Why Embedded Analytics Leads the Way
Varsha Nayak
 
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 

Writing Domain Specific Languages with JSON Schema

  • 2. Writing Domain Specific Languages with JSON Schema Yos Riady yos.io bit.ly/2JbMTrn
  • 3. Weak types in JSON What is JSON Schema? Introduction Schema Uses DSL Conclusion JSON Schema use cases Summary and further learning Writing a DSL with JSON Schema
  • 5. JSON is weakly typed { “userName”: “Yos”, “favouriteNumber”: 42, “interests”: [“programming”, “swimming”] }
  • 7. message Person { required string user_name = 1 optional int64 favourite_number = 2 repeated string interests = 3 } Protocol Buffers are strongly typed
  • 9. How can we validate JSON data with types?
  • 10. Enter JSON Schema { “userName”: { “type”: “string” }, “favouriteNumber”: { “type”: “integer” }, “interests”: { “type”: “array”, “items”: { “type”: “string”} } }
  • 11. JSON Schema helps you validate JSON data.
  • 13. JSON Schema 101 { "type": "string" } Valid Invalid “foo” 123 false
  • 14. JSON Schema Basic Types ● string ● Numeric types ● object ● array ● boolean ● null
  • 15. { "type": "object", "properties": { "userName": { "type": "string" } }, "required": ["userName"], "additionalProperties": false, } JSON Schema 101 Valid Invalid { “userName”: “foo” } { “userName”: 1 } { “name”: “foo” } {}
  • 16. JSON Schema 101 Invalid Validation Message { “userName”: 1 } Field .userName should be a string { “name”: “foo” } Should NOT have additional properties {} Should have required property ‘userName’
  • 17. Additional JSON Schema Validations { "type": "number", "minimum": 0, "maximum": 100, "exclusiveMaximum": true } { "type": "string", "pattern": "^(([0-9]{3}))?[0-9]{3}-[0-9]{4}$" }
  • 18. Combining JSON Schemas ● AnyOf ● AllOf ● OneOf ● not { "anyOf": [ { "type": "string" }, { "type": "number" } ] }
  • 19. Structuring Complex Schemas { "definitions": { "person": { ... } }, "type": "object", "properties": { "user": { "$ref": "#/definitions/person" } } }
  • 22. Use Cases for JSON Schema ● Message / data validation ○ Object Relational Mappers (ORMs) ● Schemaless objects in Web Applications ● Content Management in Headless CMSes ● Writing Specification Languages ○ OpenAPI / Swagger ○ AWS States Language ○ WAML
  • 25. Content Modeling in Headless CMSes
  • 26. Content Modeling in Headless CMSes
  • 28. Weak types in JSON What is JSON Schema? Introduction Schema Uses DSL Conclusion JSON Schema use cases Summary and further learning Writing a DSL with JSON Schema
  • 29. Writing a DSL with JSON Schema
  • 30. Domain Specific Languages ● Computer language specialized to a particular application domain ○ In contrast to General Purpose Languages (GPLs)
  • 32. Web Automation Markup Language (waml.io)
  • 34. Writing a DSL with JSON Schema "waml": { "description": "WAML Specification semantic version number.", "type": "string", "pattern": "^([0-9]{1,}.[0-9]{1,}.[0-9]{1,})$", "enum": ["0.1.0"] }
  • 35. Writing a DSL with JSON Schema "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/Step" } }
  • 36. Writing a DSL with JSON Schema "Step": { "type": "object", "description": "A step represents a single user interaction.", "oneOf": [ { "$ref": "#/definitions/VisitStep" }, { "$ref": "#/definitions/ClickStep" } ] }
  • 37. "ClickStep": { "type": "object", "properties": { "click": { "oneOf": [ { "type": "string" }, { "type": "object", "properties": { "selector": { "type": "string" }, "index": { "type": "integer", "minimum": 0 } } } ] }, }, }
  • 39. Weak types in JSON What is JSON Schema? Introduction Schema Uses DSL Conclusion JSON Schema use cases Summary and further learning Writing a DSL with JSON Schema
  • 40. ● JSON is weakly typed ● JSON Schema ○ What is JSON Schema? ○ JSON validation with JSON Schema ○ Use cases ● Domain Specific Languages ○ What are DSLs? ○ Writing a DSL with JSON Schema In Closing
  • 42. Writing Domain Specific Languages with JSON Schema Yos Riady yos.io bit.ly/2JbMTrn
  • 43. Q&A