JSON+HAL

VS.

JSON+LD

application/hal+json

GET /questionarios/696f61ca-c65c-d24ff1399da0 HTTP/1.1
Host: example.org
Accept: application/hal+json

HTTP/1.1 200 OK
Content-Type: application/hal+json
{
    "_links": {
        "self":    { "href" : "/questionario/696f61ca-c65c-d24ff1399da0" },
        "tecnico": { "href" : "/tecnico/1667c554-d9db-456a-abb2-91b481285353" }
    },
    "_embedded": {
        "tipo": {
            "_links": {
                "self": { "href" : "/tipo/984c97a1-c925-4a9c-9abd-60e217130217" },
                "pessoaJuridica" : { "href" : "/pfs/91882bed-8307-44f2-9f38-8613009f22d6" }
            },
            "descricao" : "Benfeitoria",
            "multiplaescolha": true,
        },
        "questao" : [
            {
                "_links": { "self": { "href" : "/questoes/f8035574-757a-4d23-954b-a916b34ac2c4" } },
                "descricao": "Questao 3",
                "_embedded" : {
                    "opcaoresposta" : [
                        { 
                            "_links": { "self": "/opcaorespostas/051b4f21-65f4-440b-beee-bd3a491a97d4" },
                            "descricao": "resposta 3",
                        },
                        { 
                            "_links": { "self": "/opcaorespostas/82cc2a9a-a188-497b-b675-c2fc57684d3a" },
                            "descricao": "resposta 1",
                        }
                    ]
                }
            }
        ]
    },
     "dataCriacao": "17/12/2014 12:28:27",
     "descricao": "Questionario de teste",
     "ativo": false
}
GET /questionarios/?limit=4 HTTP/1.1
Host: example.org
Accept: application/hal+json

HTTP/1.1 200 OK
Content-Type: application/hal+json
{
    "_links" : {
        "self" : { "href" : "/questionarios/?limit=4" },
        "next" : { "href" : "/questionarios/?limit=4&offset=4" },
        "findByDescricao" : { 
            "href" : "/questionario/?filer={descricao}",
            "templated" : true
        },
        "questionario": {
            "href" : "/questionario/{id}",
            "templated" : true
        }
    },
    "questionario" : [
         {
             "id" : "361b42da-512b-4617-9983-703ecc960475"
             "dataCriacao": "16/12/2014 01:46:02",
             "descricao": "Questionario de pessoa fisica",
             "ativo": true
         },{
             "id" : "bc70498a-aecb-4620-b79f-7ffadf61fdf0",
             "dataCriacao": "17/12/2014 10:51:51",
             "descricao": "wefawef",
             "ativo": false
         },{
             "id" : "72110558-5079-4317-80d4-f9ef391aa104",
             "dataCriacao": "17/12/2014 10:53:23",
             "descricao": "Meu Questionario",
             "ativo": false
         },{
             "id" : "52b95e5a-b76b-4352-9ae8-4c46f90c7cb9",
             "dataCriacao": "17/12/2014 10:58:54",
             "descricao": "Meu Questionario",
             "ativo": false
         }
    ],
    "total" : 120
}

Referencias

https://tools.ietf.org/html/draft-kelly-json-hal-06#section-4.1.1

application/ld+json

GET /questionarios/696f61ca-c65c-d24ff1399da0 HTTP/1.1
Host: example.org
Accept: application/ld+json
HTTP/1.1 200 OK
Content-Type: application/ld+json
{
    "@context": {
        "@id" : "http://json-ld.org/contexts/person.jsonld",
    },
    "id" : "696f61ca-d9db-456a-abb2-d24ff1399da0",
    "tecnico": "1667c554-d9db-456a-abb2-91b481285353",
    "tipo" : {
            "id" : "984c97a1-c925-4a9c-9abd-60e217130217",
            "descricao" : "Benfeitoria",
            "multiplaescolha": true,
            "pessoaJuridica" : { "id" : "91882bed-8307-44f2-9f38-8613009f22d6" }
    },
    "questao" : [
            {
                "id" : "f8035574-757a-4d23-954b-a916b34ac2c4",
                "descricao": "Questao 3",
                "opcaoresposta" : [
                    { 
                        "id" : "051b4f21-65f4-440b-beee-bd3a491a97d4",
                        "descricao": "resposta 3",
                    },
                    { 
                        "id" : "82cc2a9a-a188-497b-b675-c2fc57684d3a",
                        "descricao": "resposta 1",
                    }
                ]
            }
        ]
    },
     "dataCriacao": "17/12/2014 12:28:27",
     "descricao": "Questionario de teste",
     "ativo": false
}
GET /questionarios/?limit=4 HTTP/1.1
Host: example.org
Accept: application/ld+json

HTTP/1.1 200 OK
Content-Type: application/ld+json
{
    "@context" : {
        "questionario" : {
            "@id" : "http://example.org/questionario.jsonld",
            "@container" : "@list"
        },
        "total" : "http://example.org/integer.jsonld"
    },
   "questionario" : [
            {
                "id" : "361b42da-512b-4617-9983-703ecc960475",
                "dataCriacao": "16/12/2014 01:46:02",
                "descricao": "Questionario de pessoa fisica",
                "ativo": true
            },{
                "id" : "bc70498a-aecb-4620-b79f-7ffadf61fdf0",
                "dataCriacao": "17/12/2014 10:51:51",
                "descricao": "wefawef",
                "ativo": false
            },{
                "id" : "72110558-5079-4317-80d4-f9ef391aa104",
                "dataCriacao": "17/12/2014 10:53:23",
                "descricao": "Meu Questionario",
                "ativo": false
            },{
                "id": "/questionarios/52b95e5a-b76b-4352-9ae8-4c46f90c7cb9",
                "dataCriacao": "17/12/2014 10:58:54",
                "descricao": "Meu Questionario",
                "ativo": false
            }
        ]
    }
    "total" : 120
}

Referencias

http://www.w3.org/TR/json-ld/

URI Resource

http://exemplo.org/{tipo}

Lista

http://exemplo.org/{tipo}/{uuid}

Registro

http://exemplo.org/{tipo}/{uuid}/{tipo_rel}

Lista de Objetos Relacionados

http://exemplo.org/{tipo}/{uuid}/{tipo_rel}/{uuid}

Registro de ObjetoRelacionado

Made with Slides.com