Skip to main content
4 of 4
edited tags
Kevin Montrose
  • 18.7k
  • 6
  • 35
  • 62

associated_users does not have a root level key

in order to uniquely identify a associated_users on must traverse the object graph into the onsite object and construct an artificial key.

it makes more sense to either flatten the structure or, more appropriately in my opinion, simply use a site key instead of duplicating data that, if desired, can be pulled from the /sites route.

this is an example of where a decent site key would come in handy, but if, as insisted, a mixed case string with, currently, spaces and who knows what else in the future, is what we have for a key then please surface that on the result.

the current structure is unnatural and the nested object graph complicates consumption unnecessarily.

Current:

{
  "associated_users": [
    {
      "user_id": 242897,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 9272,
      "on_site": {
        "name": "Stack Overflow",
        "logo_url": "http://sstatic.net/so/img/logo.png",
        "api_endpoint": "http://api.stackoverflow.com",
        "site_url": "http://stackoverflow.com",
        "description": "Q&A for programmers",
        "icon_url": "http://sstatic.net/so/apple-touch-icon.png"
      },
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    },
    {
      "user_id": 38306,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 111,
      "on_site": {
        "name": "Server Fault",
        "logo_url": "http://sstatic.net/sf/img/logo.png",
        "api_endpoint": "http://api.serverfault.com",
        "site_url": "http://serverfault.com",
        "description": "Q&A for system administrators and IT professionals",
        "icon_url": "http://sstatic.net/sf/apple-touch-icon.png"
      },
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    },
    {
      "user_id": 31747,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 100,
      "on_site": {
        "name": "Super User",
        "logo_url": "http://sstatic.net/su/img/logo.png",
        "api_endpoint": "http://api.superuser.com",
        "site_url": "http://superuser.com",
        "description": "Q&A for computer enthusiasts and power users",
        "icon_url": "http://sstatic.net/su/apple-touch-icon.png"
      },
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    },
    {
      "user_id": 144906,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 1252,
      "on_site": {
        "name": "Stack Overflow Meta",
        "logo_url": "http://sstatic.net/mso/img/logo.png",
        "api_endpoint": "http://api.meta.stackoverflow.com",
        "site_url": "http://meta.stackoverflow.com",
        "description": "Q&A about Stack Overflow, Server Fault, and Super User",
        "icon_url": "http://sstatic.net/mso/apple-touch-icon.png"
      },
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    },
    // stackapss  missing
    {
      "user_id": 14,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 3123,
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    }
  ]
}

Proposed: (i would be happy to meet you half way and tolerate the nested on_site node if only we can get the site id on the root as shown)

{
  "associated_users": [
    {
      "user_id": 242897,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 9272,
      "site_name": "Stack Overflow",
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    },
    {
      "user_id": 38306,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 111,
      "site_name": "Server Fault",
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    },
    {
      "user_id": 31747,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 100,
      "site_name": "Super User",
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    },
    {
      "user_id": 144906,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 1252,
      "site_name": "Stack Overflow Meta",
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    },
    {
      "user_id": 14,
      "user_type": "registered",
      "display_name": "code poet",
      "reputation": 3123,
      "email_hash": "df4a7fbd8a054fd6193ca0ee62952f1f"
    }
  ]
}
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60