Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way for JSON requests to specify the format #11

Open
Eldelshell opened this issue Apr 21, 2013 · 1 comment
Open

Add a way for JSON requests to specify the format #11

Eldelshell opened this issue Apr 21, 2013 · 1 comment
Assignees

Comments

@Eldelshell
Copy link
Owner

Eldelshell commented Apr 21, 2013

The idea is to allow different JSON formats which can be used with different REST clients.

The default format is:

{
  "success":true,
  "status":"OK",
  "rows":[
    {
      "roi":0,
      "cells":{
        "birthday":"1982-12-13",
        "name":"foo",
        "id":0,
        "lastupdate":"2020-05-08T21:17:21.993+02:00",
        "credit":32.50,
        "age":30
      }
    }
  ],
  "resource":"users",
  "pagination":{
    "page":1,
    "size":6,
    "pages":1,
    "total":6
  }
}

To allow this, we can either use:

  • a map JSON file set with configuration
  • During runtime with a POST endpoint which receives the format JSON data.
  • Allow GET endpoints to accept POST requests with the format JSON data.

The format data would look like:

{
  "formats": [
    {
      "resource": "users",
      "meta": {
        "success": true,
        "status": false,
        "pagination": true
      },
      "model": {
        "id": "number",
        "name": "string",
        "birthday": "dd/MM/yyyy",
        "credit": "number"
      }
    },{
      "resource": "cars",
      "meta": null,
      "model": {
        "id": "number",
        "maker": "string",
        "lastUpdate": "ddMMyyyyhhmmss"
      }
    }
  ]
}

A response from users then would be formatted as:

{
  "success":true,
  "pagination":{
    "page":1,
    "size":6,
    "pages":1,
    "total":6
  },
  "entities": [
    {
      "id":0,
      "name":"foo",
      "birthday":"13/12/1982",
      "credit":32.50
    }
  ]
}

And a response from cars (with no metadata) would look like:

{
  "id":0,
  "maker":"foo",
  "lastUpdate":"13121982040130"
}
@ghost ghost assigned Eldelshell Apr 21, 2013
@Eldelshell Eldelshell removed this from the Release 0.3 milestone Apr 30, 2020
@Eldelshell
Copy link
Owner Author

It might be also be possible to set "meta": "head" so the pagination is received as HTTP headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant