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

Serializer #1

Open
koraykoska opened this issue Jan 21, 2017 · 1 comment
Open

Serializer #1

koraykoska opened this issue Jan 21, 2017 · 1 comment

Comments

@koraykoska
Copy link
Member

The serializer is responsible for serializing a jsonapi String into a usable Java Object which represents either the Resource object (which should be a generic Type) or an Error object.

For example the following string should be serialized into an java object which represents articles and contains all attributes and the included objects.

{
  "data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!",
      "body": "The shortest article. Ever.",
      "created": "2015-05-22T14:56:29.000Z",
      "updated": "2015-05-22T14:56:28.000Z"
    },
    "relationships": {
      "author": {
        "data": {"id": "42", "type": "people"}
      }
    }
  }],
  "included": [
    {
      "type": "people",
      "id": "42",
      "attributes": {
        "name": "John",
        "age": 80,
        "gender": "male"
      }
    }
  ]
}

The following should be serialized into an Error object:

{
  "errors": [
    {
      "status": "422",
      "source": { "pointer": "/data/attributes/first-name" },
      "title":  "Invalid Attribute",
      "detail": "First name must contain at least three characters."
    }
  ]
}

The serializer package may not be dependent upon other packages or classes but rather be a module which is also usable without the rest of this library.
This leads to a module which can be used by people who want to use flick as a jsonapi serializer but want to manage HTTP requests on their own.

@koraykoska
Copy link
Member Author

Json parsing should be done with gson

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

No branches or pull requests

1 participant