Collection+JSON is a JSON-based read/write hypermedia-type designed to support management and querying of simple collections.

Definitions

Definition Title Type Description
collection Collection+JSON Object object The main Collection+JSON Object
items Collection+JSON Items Array array An array of item objects
item Collection+JSON Item Object object An item object
queries Collection+JSON Query Array array An array of query objects
query Collection+JSON Query Object object A query object
template Collection+JSON Template Object object A template object
dataPropertyArray Collection+JSON Data Property Array array An array of data property objects
dataPropertyObject Collection+JSON Data Property Object object A data property object
dataTemplateArray Collection+JSON Data Template Array array An array of data template objects
dataTemplateObject Collection+JSON Data Template Object object A data template object

Schema

{
  "type": "object",
  "properties": {
    "collection": {
      "$ref": "#/definitions/collection"
    }
  },
  "required": [
    "collection"
  ],
  "definitions": {
    "collection": {
      "title": "Collection+JSON Object",
      "description": "The main Collection+JSON Object",
      "type": "object",
      "properties": {
        "version": {
          "$ref": "http://hyperschema.org/core/meta#/definitions/version"
        },
        "href": {
          "$ref": "http://hyperschema.org/core/link#/definitions/href"
        },
        "links": {
          "$ref": "#/definitions/links"
        },
        "items": {
          "$ref": "#/definitions/items"
        },
        "queries": {
          "$ref": "#/definitions/queries"
        },
        "templates": {
          "$ref": "#/definitions/templates"
        }
      }
    },
    "links": {
      "title": "Collection+JSON Link Array",
      "description": "An array of link objects",
      "type": "array",
      "items": {
        "$ref": "#/definitions/link"
      }
    },
    "link": {
      "title": "Collection+JSON Link Object",
      "description": "An object with link information",
      "type": "object",
      "properties": {
        "rel": {
          "$ref": "http://hyperschema.org/core/link#/definitions/rel"
        },
        "href": {
          "$ref": "http://hyperschema.org/core/link#/definitions/href"
        },
        "prompt": {
          "$ref": "http://hyperschema.org/core/link#/definitions/label"
        }
      },
      "required": [
        "href",
        "rel"
      ]
    },
    "items": {
      "title": "Collection+JSON Items Array",
      "description": "An array of item objects",
      "type": "array",
      "items": {
        "$ref": "#/definitions/item"
      }
    },
    "item": {
      "title": "Collection+JSON Item Object",
      "description": "An item object",
      "type": "object",
      "properties": {
        "href": {
          "$ref": "http://hyperschema.org/core/link#/definitions/href"
        },
        "data": {
          "$ref": "#/definitions/dataPropertyArray"
        },
        "links": {
          "$ref": "#/definitions/links"
        }
      }
    },
    "queries": {
      "title": "Collection+JSON Query Array",
      "description": "An array of query objects",
      "type": "array",
      "items": {
        "$ref": "#/definitions/query"
      }
    },
    "query": {
      "title": "Collection+JSON Query Object",
      "description": "A query object",
      "type": "object",
      "properties": {
        "rel": {
          "$ref": "http://hyperschema.org/core/link#/definitions/rel"
        },
        "href": {
          "$ref": "http://hyperschema.org/core/link#/definitions/href"
        },
        "prompt": {
          "$ref": "http://hyperschema.org/core/link#/definitions/label"
        },
        "data": {
          "$ref": "#/definitions/dataPropertyArray"
        }
      },
      "required": [
        "href",
        "rel"
      ]
    },
    "template": {
      "title": "Collection+JSON Template Object",
      "description": "A template object",
      "type": "object",
      "properties": {
        "data": {
          "$ref": "#/definitions/dataTemplateArray"
        }
      }
    },
    "dataPropertyArray": {
      "title": "Collection+JSON Data Property Array",
      "description": "An array of data property objects",
      "type": "array",
      "items": {
        "$ref": "#/definitions/dataPropertyObject"
      }
    },
    "dataPropertyObject": {
      "title": "Collection+JSON Data Property Object",
      "description": "A data property object",
      "type": "object",
      "properties": {
        "name": {
          "$ref": "http://hyperschema.org/core/properties#/definitions/name"
        },
        "value": {
          "$ref": "http://hyperschema.org/core/properties#/definitions/value"
        },
        "prompt": {
          "$ref": "http://hyperschema.org/core/properties#/definitions/label"
        }
      },
      "required": [
        "name"
      ]
    },
    "dataTemplateArray": {
      "title": "Collection+JSON Data Template Array",
      "description": "An array of data template objects",
      "type": "array",
      "items": {
        "$ref": "#/definitions/dataTemplateObject"
      }
    },
    "dataTemplateObject": {
      "title": "Collection+JSON Data Template Object",
      "description": "A data template object",
      "type": "object",
      "properties": {
        "name": {
          "$ref": "http://hyperschema.org/core/fields#/definitions/name"
        },
        "value": {
          "$ref": "http://hyperschema.org/core/fields#/definitions/value"
        },
        "prompt": {
          "$ref": "http://hyperschema.org/core/fields#/definitions/label"
        }
      },
      "required": [
        "name"
      ]
    }
  }
}

Example Message

{
  "collection": {
    "version": "1.0",
    "href": "http://example.org/friends/",
    "links": [
      {
        "rel": "feed",
        "href": "http://example.org/friends/rss"
      }
    ],
    "items": [
      {
        "href": "http://example.org/friends/jdoe",
        "data": [
          {
            "name": "full-name",
            "value": "J. Doe",
            "prompt": "Full Name"
          },
          {
            "name": "email",
            "value": "jdoe@example.org",
            "prompt": "Email"
          }
        ],
        "links": [
          {
            "rel": "blog",
            "href": "http://examples.org/blogs/jdoe",
            "prompt": "Blog"
          },
          {
            "rel": "avatar",
            "href": "http://examples.org/images/jdoe",
            "prompt": "Avatar",
            "render": "image"
          }
        ]
      },
      {
        "href": "http://example.org/friends/msmith",
        "data": [
          {
            "name": "full-name",
            "value": "M. Smith",
            "prompt": "Full Name"
          },
          {
            "name": "email",
            "value": "msmith@example.org",
            "prompt": "Email"
          }
        ],
        "links": [
          {
            "rel": "blog",
            "href": "http://examples.org/blogs/msmith",
            "prompt": "Blog"
          },
          {
            "rel": "avatar",
            "href": "http://examples.org/images/msmith",
            "prompt": "Avatar",
            "render": "image"
          }
        ]
      },
      {
        "href": "http://example.org/friends/rwilliams",
        "data": [
          {
            "name": "full-name",
            "value": "R. Williams",
            "prompt": "Full Name"
          },
          {
            "name": "email",
            "value": "rwilliams@example.org",
            "prompt": "Email"
          }
        ],
        "links": [
          {
            "rel": "blog",
            "href": "http://examples.org/blogs/rwilliams",
            "prompt": "Blog"
          },
          {
            "rel": "avatar",
            "href": "http://examples.org/images/rwilliams",
            "prompt": "Avatar",
            "render": "image"
          }
        ]
      }
    ],
    "queries": [
      {
        "rel": "search",
        "href": "http://example.org/friends/search",
        "prompt": "Search",
        "data": [
          {
            "name": "search",
            "value": ""
          }
        ]
      }
    ],
    "template": {
      "data": [
        {
          "name": "full-name",
          "value": "",
          "prompt": "Full Name"
        },
        {
          "name": "email",
          "value": "",
          "prompt": "Email"
        },
        {
          "name": "blog",
          "value": "",
          "prompt": "Blog"
        },
        {
          "name": "avatar",
          "value": "",
          "prompt": "Avatar"
        }
      ]
    }
  }
}