Event Details API Schema
Yhippa.9046:
I’m using the Jackson JSON library in Java to deserialize the Event Details data. One thing I noticed is that it seems that Event IDs are being used as a field in the Event Details returned objects. For example let’s say I make this call: https://api.guildwars2.com/v1/event_details.json?event_id=16554045-EFE8-4248-8B78-E4BB46CA94F5. In return I get this back:
{
"events": {
"16554045-EFE8-4248-8B78-E4BB46CA94F5": {
"name": "Stop the skritt burglar before it escapes with the treasure.",
"level": 29,
"map_id": 24,
"flags": [],
"location": {
"type": "sphere",
"center": [
-12077.3,
-1391.04,
-204.884
],
"radius": 3500,
"rotation": 0
}
}
}
}
The way it’s written it looks like Event ID is actually a field and not an attribute. This doesn’t smell right to me since that implies that my Events object would have n fields where n is the number of events. I’v never seen JSON structured this way. Any thoughts on how to parse this in an object-oriented manner?
famfamfam.9137:
JSON does not differentaite between fields/attributes; What you’re seeing is just a fairly standard JSON-object hierarchy keyed by ID. To deserialize these you’d need to iterate them manually and build your objects rather than attempt to flat map JSON values directly to OO-language object properties.
Have you considered using one of the community Java libraries from https://forum-en.guildwars2.com/forum/community/api/API-implementation-library-master-list/?