Introduction

This section includes all the specifications of json concepts. A file that ends with .concepts.json is referred as a concepts definition throughout this document. Below is an example of a concepts definition;

CONCEPTS: service.concepts.json

{
    "$service+": {
        "$parameter*": "$type",
        "response": "$responseType"
    }
}

This definition represents a meta-schema that will validate a schema like below;

SCHEMA: greeting.service.json

{
    "sayHello": {
        "name": "string",
        "response": "string"
    }
}

About Syntax

To keep its syntax short, json concepts makes a heavy use of special characters. This is a design decision to have an expressive syntax, just like regular expressions.

There are two basic questions to choose a special character;

  1. Does it mean only one thing?
  2. Is it familiar?

If the answer is yes to both questions, then that special character is a good choice.

A special character is considered to be familiar either because it has the same meaning in another well-known language or specification, or because its name or shape makes sense in the context it is used.

Any special character that doesn't suit well to this approach is subject to a change.

CharacterMeaningFamiliarityStatus
$variablevariables in php, bash, powershell👍
#macroc, c++, c# preprocessor directives👍
!forcecss important👍
@meta-datajava annotations👍
?zero or oneregex, ternary operator👍
+one or moreregex👍
{,}quantifierregex👍
:typespecifying type in uml, swift or scala👍
*zero or more & anyregex & file path wildcard🤔
**any childfile path wildcard👍
/pathfile paths, urls👍
..parentfile paths👍
...spreadjavascript spread operator👍
\escapeescape character👍
&andbitwise and👍
|orbitwise or👍
[]set default keyjavascript property accessor🤔
()set default value & pluralizationfunction call & plain english, e.g. item(s)🤔
^from beginningregex start🤔
-shift leftminus sign🤔

About Specifications

Every specification introduces a new feature of json concepts. Each spec is written assuming that you have read the specs before that one. There will be one or more cases to clearly define a feature. Just like above examples, there will be a sample concepts definition and a sample schema to demonstrate a case.

CONCEPTS: sample.concepts.json

{
    "$sample*": "$definition"
}

These concepts definitions are usually followed by a schema;

SCHEMA: schema.sample.json

{
    "schema": "defined"
}

Another Case

When there is more than one case, following cases will be in a different heading.

If there is a need for an example code, it will be in javascript.

CODE: sample.js

const schema = Schema.load('schema.sample.json', 'sample.concepts.json');

console.log(schema.definition);

When the case is an error case, expected error message will be specified like this;

ERROR: an expected error message

This does not mean that such an error message is expected word by word. It is rather a suggestion for a potential implementation.

Final Word

Although json concepts is only a specification, there is a Node.js implementation as well. This implementation serves as a proof of concept that validates this specification.