StevenL.3761:

My caching algorithm requires that API response objects have some indication of what they represent. Currently, this is not the case for map_floor objects.

My suggestion is to add the continent_id and floor values as properties.

Example: /v1/map_floor.json?continent_id=1&floor=1


        {
            continent_id: 1,
            floor: 1,
            texture_dims: [...]
            regions: {...}
        }
 

 —
 
Thank you

smiley.1438:

You have those values already in your request, where’s the problem to add these to the response object by yourself?

StevenL.3761:

That’s how I’m doing it now, but it’s a hack. The ugliest one so far.

The problem is that my request and response objects are decoupled, so the response object knows nothing about the origin of the data. I use manager classes to put all the pieces together. The fact that the response data does not contain identifiers puts the web service manager in a position where it has to fill in those blanks, rather than the JSON serializer.

smiley.1438:

That’s how I’m doing it now, but it’s a hack. The ugliest one so far.

Redundant data is even uglier. Seriously.

StevenL.3761:

It’s a simple association property. Or navigation property. Or however you want to call it. Anyway, they are just identifiers. Redundancy is not an argument here.

edit

Just for funsies, try and tell me which continent and floor this data belongs to:



{
   "texture_dims":[
      32768,
      32768
   ],
   "clamped_view":[
      [
         1662,
         2816
      ],
      [
         12544,
         8062
      ]
   ],
   "regions":{
      "29":{
         "name":"Super Adventure Box",
         "label_coord":[
            6272,
            2432
         ],
         "maps":{
            "935":{
               "name":"Super Adventure Box",
               "min_level":1,
               "max_level":80,
               "default_floor":20,
               "map_rect":[
                  [
                     -15360,
                     -30720
                  ],
                  [
                     15360,
                     30720
                  ]
               ],
               "continent_rect":[
                  [
                     1574,
                     5972
                  ],
                  [
                     2854,
                     8532
                  ]
               ],
               "points_of_interest":[
                  {
                     "poi_id":1824,
                     "name":"",
                     "type":"waypoint",
                     "floor":20,
                     "coord":[
                        2206.49,
                        7275.1
                     ]
                  }
               ],
               "tasks":[

               ],
               "skill_challenges":[

               ],
               "sectors":[
                  {
                     "sector_id":1128,
                     "name":"Super Adventure Box",
                     "level":80,
                     "coord":[
                        2175.26,
                        7206.06
                     ]
                  }
               ]
            }
         }
      }
   }
}