Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create compound documents?

Tags:

json-api

I'm thinking of using the JSONAPI standard for the design of our API. One thing this API must be able to do, is accept a compound document (several layers deep) and create it. The root object owns all descendants ('to-many' relationships) which the server knows nothing about at that point, so it's not possible for the client to provide an id.

Is this supported by the specification or does the client have to issue http requests for every object in the document in order?

like image 945
Jeroen Knoef Avatar asked Jun 08 '15 08:06

Jeroen Knoef


People also ask

What does a compound document contain?

A single document that contains a combination of data structures such as text, graphics, spreadsheets, sound and video clips. The document may embed the additional data types or reference external files by pointers of some kind. SGML and HTML are examples of compound document formats.

What is compound document in FileNet?

A FileNet P8 compound document is a group of hierarchically organized component documents that can be assembled to form a single document. The root document at the top of the hierarchy is called the parent component; this component can have zero or more subcomponents, called child components.

Is a technology that enables an application to create compound documents that Containinformation from a number of different sources?

OLE compound documents enable users working within a single application to manipulate data written in various formats and derived from multiple sources.


1 Answers

from http://jsonapi.org/format/#document-compound-documents

Compound documents require "full linkage", meaning that every included resource MUST be identified by at least one resource identifier object in the same document. These resource identifier objects could either be primary data or represent resource linkage contained within primary or included resources. The only exception to the full linkage requirement is when relationship fields that would otherwise contain linkage data are excluded via sparse fieldsets.

{
  "data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!"
    },
    "links": {
      "self": "http://example.com/articles/1"
    },
    "relationships": {
      "author": {
        "links": {
          "self": "http://example.com/articles/1/relationships/author",
          "related": "http://example.com/articles/1/author"
        },
        "data": { "type": "people", "id": "9" }
      },
      "comments": {
        "links": {
          "self": "http://example.com/articles/1/relationships/comments",
          "related": "http://example.com/articles/1/comments"
        },
        "data": [
          { "type": "comments", "id": "5" },
          { "type": "comments", "id": "12" }
        ]
      }
    }
  }],
  "included": [{
    "type": "people",
    "id": "9",
    "attributes": {
      "first-name": "Dan",
      "last-name": "Gebhardt",
      "twitter": "dgeb"
    },
    "links": {
      "self": "http://example.com/people/9"
    }
  }, {
    "type": "comments",
    "id": "5",
    "attributes": {
      "body": "First!"
    },
    "links": {
      "self": "http://example.com/comments/5"
    }
  }, {
    "type": "comments",
    "id": "12",
    "attributes": {
      "body": "I like XML better"
    },
    "links": {
      "self": "http://example.com/comments/12"
    }
  }]
}
like image 157
equivalent8 Avatar answered Sep 30 '22 20:09

equivalent8