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

Known Clients to deserialize this format of API #159

Closed
emaillenin opened this issue Apr 9, 2018 · 2 comments
Closed

Known Clients to deserialize this format of API #159

emaillenin opened this issue Apr 9, 2018 · 2 comments

Comments

@emaillenin
Copy link

emaillenin commented Apr 9, 2018

Are there any known libs in Java that can deserialize the JSON produce by this library? I have been using RABL before and serializing the data in flat structure with relationship attributes baked into the root object. Fast JSON API is producing output with the main object and the relationships separately like this:

{
  "data": [
    {
      "id": "8388",
      "type": "upcoming_match",
      "attributes": {
        "id": 8388,
        "start_date": "2018-04-09T14:30:00.000Z",
        "start_datetime": "2018-04-09T14:30:00.000Z",
        "number": "4th Match",
        "match_type": 6,
        "match_type_desc": "T20",
        "name": "4th Match - Sunrisers Hyderabad Vs Rajasthan Royals on 9 April 2018",
        "series_id": 1797,
        "is_live": true,
        "has_selected_team": false
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "5",
              "type": "team"
            },
            {
              "id": "4",
              "type": "team"
            }
          ]
        }
      }
    }
  ],
  "included": [
    {
      "id": "5",
      "type": "team",
      "attributes": {
        "id": 5,
        "name": "Sunrisers Hyderabad",
        "flag_thumb": "https://elasticbeanstalk-us-west-2-520152758970.s3-us-west-2.amazonaws.com/www/teams/5_17a21e668f7aa5017248dc4585570a3a6526dcf9_thumb.png?1408803408"
      }
    },
    {
      "id": "4",
      "type": "team",
      "attributes": {
        "id": 4,
        "name": "Rajasthan Royals",
        "flag_thumb": "https://elasticbeanstalk-us-west-2-520152758970.s3-us-west-2.amazonaws.com/www/teams/4_301f221783a033b2fef98a680eb132420bae55e4_thumb.png?1408803398"
      }
    }
  ]
}

Usually, I have seen APIs including the relationship data within the parent node (i.e. teams within each match in this example). But Fast JSON API is including them separately as a list. Is this a new pattern of exposing relationships and includers? My API client is in Java. I am using https://github.com/FasterXML/jackson to access the API. Instead of writing complex classes that maps this JSON, is there a recommended client that lets me navigate the JSON easily? Like for example,

document.getUpcomingMatch("8388").getTeams().get(0).getFlagThumb()

@aldreth
Copy link

aldreth commented Apr 18, 2018

Have you tried either of the suggestions here http://jsonapi.org/implementations/#client-libraries-java ?

@emaillenin
Copy link
Author

That is what I'm looking for. Thanks!

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

2 participants