BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Ajv Joins the OpenJS Foundation

Ajv Joins the OpenJS Foundation

This item in japanese

Bookmarks

Ajv, a JSON Schema validator for both server-side and client-side JavaScript applications, has joined the OpenJS Foundation. Ajv, which was recently awarded a grant from Mozilla’s Open Source Support (MOSS) program, may benefit from the OpenJS infrastructure and organization to grow the number of contributors and foster wider enterprise adoption, while working on supporting the newer JSON Type Definition (JTD) proposal.

Ajv’s project lead Evgeny Poberezkin explained why Ajv sought external support:

The current version of JSON Schema (version 8 – draft 2019-09) introduced 2 substantial validation paradigm changes. The additional features increased implementation complexity – to consistently implement these features in Ajv will require substantial re-write. Also, a new promising standard for JSON validation appeared – JSON Type Definition (JTD).
Ajv users are interested in the support of the latest JSON version, but it was not sustainable for me to implement it in my free time – it is a large amount of work, particularly given how important it is to allow all existing users to migrate without disruption
[…]
As Ajv became a part of millions of web applications, having [the OpenJS Foundation] support will ensure the longevity and stability of Ajv for all users.

While Ajv has gathered close to 100 contributors, Ajv’s development has been largely supported by a single developer.

Gajus Kuizinas, CTO of Contra, commented positively on the new OpenJS member:

Ajv has become a centerpiece of all data-validation logic in my open-source projects and businesses. It’s spec-compliant, extensible, fast and has amazing support. Ajv joining the OpenJS Foundation will greatly benefit the entire JavaScript ecosystem.

Ajv, which stands for Another JSON Schema Validator, started development five years ago and supported the JSON Schema standard version 4. Ajv now supports version 7 of the JSON standard. Ajv is also extensible via custom keywords and plugins, and is one of the fastest JSON Schema validators according to some benchmarks.

JSON (JavaScript Object Notation) is a lightweight data-interchange format that strives to be easy for humans to read and write, and easy for machines to parse and generate. JSON is meant to describe hierarchical data structures in a concise way.

JSON Schema is a vocabulary used to annotate and validate JSON documents. The main use of a JSON schema is to describe the structure and validation constraints of a JSON document. Data validation is useful for automated testing and ensuring the quality of client-submitted data.

JSON Schema is currently at the draft stage – the latest version, draft-08, was published in September 2019. The JSON Schema project intends to shepherd all four draft series to RFC status and become an official standard.

An example of schema is as follows:

{
  "$id": "https://example.com/arrays.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "A representation of a person, company, organization, or place",
  "type": "object",
  "properties": {
    "fruits": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "vegetables": {
      "type": "array",
      "items": { "$ref": "#/definitions/veggie" }
    }
  },
  "definitions": {
    "veggie": {
      "type": "object",
      "required": [ "veggieName", "veggieLike" ],
      "properties": {
        "veggieName": {
          "type": "string",
          "description": "The name of the vegetable."
        },
        "veggieLike": {
          "type": "boolean",
          "description": "Do I like this vegetable?"
        }
      }
    }
  }
}

An instance of data satisfying the schema is as follows:

{
  "fruits": [ "apple", "orange", "pear" ],
  "vegetables": [
    {
      "veggieName": "potato",
      "veggieLike": true
    },
    {
      "veggieName": "broccoli",
      "veggieLike": false
    }
  ]
}

Ajv is available under the MIT open-source license. Contributions are welcome. The Ajv core contributor is currently looking for long-term maintainers to share the ownership of Ajv.

Rate this Article

Adoption
Style

BT