- Research Area
- Introduction
- Type System
- version 2 roadmap
- MIMUW
- Using nianio pattern in JS
- Using nianio pattern in C
- Introduction to json-ptd technology
- json-ptd specification
- PHP json-ptd validator documentation
- JavaScript json-ptd validator documentation
- JavaScript json-ptd validator
JavaScript json-ptd validator
After reading this documentation, you will be able to start using the JavaScript json-ptd validator library in your own JavaScript projects. Before using the validator you should be familiarised with the “Introduction to json-ptd technology”.
What is json-ptd validator?
json-ptd validator is a library that allows you to validate JSON using a defined type. In other words, you are able to verify that the JSON structure and data types are exactly as you expect.
Eventually, json-ptd validators will be available in the following programming languages: JavaScript, PHP, Nianiolang, C#, Java.
How to use json-ptd validator?
json-ptd validator
is simple application which interface allows user to enter type
and value
in proper text areas.
By clicking Validate
button validation of type with values is triggered.
Source files includes json-ptd.js
file. This script is used to perform validation operation. You can use this file in any of your JavaScript projects.
Function jsonptd.verify
requires 3 arguments, which are value
(JSON parsed value), typeName
(name of the type) and typeLib
(JSON parsed type).
- Prepare your own type definition.
- Download json-ptd validator and import
json-ptd.js
file to your project:<script src="json-ptd.js"></script>
- Parse your type library using
JSON.parse()
function. - Parse your JSON value using
JSON.parse()
function. - Validate value with the type using
verify
function:if (jsonptd.verify(parsedValue, typeName, parsedTypeLibrary)) { console.log("Success!"); } else { console.log("The value does not conform to the type!"); }
Download json-ptd validator
https://github.com/atinea-nl/json-ptd