Skip to content

Normalised Output: Event to valid Event

thill-odi edited this page Jul 9, 2020 · 7 revisions

In the case of this example (taken from a real feed), there is no need to squash a hierarchy, as the original representation is flat. However, the data item itself is invalid in several respects - either because the values given are not structured in a valid way (as for e.g. activity, logo, and programme), or because the properties themselves are not found in the specification.

In cases where the problem is structural (typically, that a string takes the place of a complex object), the string should be used to construct the complex object, as illustrated below. In cases where the difficulty is of a string for a simple datatype (for instance, instead of a URL) it should be preserved unchanged.

Properties that are not defined in the specification, and do not have the beta: prefix, should be wrapped in an 'invalidAttribute` object.

Properties that have values such as empty strings, null, or empty arrays, should be stripped from the normalised object, in accordance with the Opportunity specification.

Before Normalisation

{
  "state": "updated",
  "kind": "Session",
  "id": 616,
  "modified": "2014-09-15T09:12:51.706+01:00",
  "data": {
    "@context": [
      "https://www.openactive.io/ns/oa.jsonld",
      "https://www.openactive.io/ns-beta/oa.jsonld"
    ],
    "type": "Event",
    "organizer": {
      "type": "Organization",
      "url": "http://www.goodgym.org/?utm_medium=openactive&utm_source=default",
      "name": "GoodGym",
      "telephone": "0203 432 3920",
      "email": "[email protected]",
      "logo": "https://www.goodgym.org/assets/goodgym_red-688adde9f7d011eb16c0cafa461d8f214e93fdefe2044d10f6cf68fee52c1584.png"
    },
    "name": "Hill Session with Tom",
    "identifier": 616,
    "id": "http://www.goodgym.org/api/happenings/hill-session-with-tom",
    "url": "http://www.goodgym.org/happenings/hill-session-with-tom?utm_medium=openactive&utm_source=default",
    "description": "Come along for a challenging but rewarding interval session with Tom!\nAfter a warm up and running drills we'll be getting stuck into sets or short, fast hills that help develop speed and power, mixing these with race effort running. Come along, get fitter, simple!\nThe session is tough but reward to totally achievable FOR ALL ABILITIES!\nMeeting at Mile End Park, at the base of the Green Bridge at the southern end.\n",
    "beta:formattedDescription": "Come along for a challenging but rewarding interval session with Tom!\r\n\r\nAfter a warm up and running drills we'll be getting stuck into sets or short, fast hills that help develop speed and power, mixing these with race effort running. Come along, get fitter, simple!\r\n\r\nThe session is tough but reward to totally achievable FOR ALL ABILITIES!\r\n\r\nMeeting at Mile End Park, at the base of the Green Bridge at the southern end.",
    "disambiguatingDescription": "A short, but tough session for speed and power",
    "activity": [
      "Running"
    ],
    "programme": "Training Session",
    "startDate": "2014-09-23T18:45:00+01:00",
    "endDate": "2014-09-23T20:40:00+01:00",
    "duration": "PT115M",
    "location": {
      "type": "Place",
      "address": {
        "type": "PostalAddress",
        "streetAddress": "Mile End Park ",
        "addressLocality": "London",
        "postalCode": "E3 4PL"
      },
      "geo": {
        "type": "GeoCoordinates",
        "latitude": 51.52462,
        "longitude": -0.0354348
      },
      "areaServed": null,
      "beta:meetingPoint": "",
      "description": ""
    },
    "toLocation": [],
    "remainingAttendeeCapacity": 22,
    "maximumAttendeeCapacity": 25,
    "leader": {
      "name": null,
      "email": null,
      "description": null
    },
    "beta:distance": {
      "value": 6,
      "unit": "KMT"
    },
    "beta:level": "intermediate",
    "beta:hasCoaching": false,
    "beta:registrationCount": 3,
    "image": null,
    "ageRange": "18",
    "genderRestriction": "mixed",
    "isAccessibleForFree": true,
    "publicAccess": true,
    "beta:orderPostUrl": "http://www.goodgym.org/api/external_registrations",
    "offers": {
      "type": "Offer",
      "id": "http://www.goodgym.org/api/happenings/hill-session-with-tom#offer",
      "price": "0"
    }
  }
}

After Normalisation

{
  "state": "updated",
  "kind": "Event",
  "id": 616,
  "modified": "2014-09-15T09:12:51.706+01:00",
  "data": {
    "@context": [
      "https://openactive.io/",
      "https://openactive.io/ns-beta"
    ],
    "type": "Event",
    "provenanceInformation": {
        "feedUrl": ["https://www.goodgym.org/api/happenings"],
        "publisherName": "GoodGym",
        "parentId" : ["http://www.goodgym.org/api/happenings/hill-session-with-tom"]
    },
    "organizer": {
      "type": "Organization",
      "url": "http://www.goodgym.org/?utm_medium=openactive&utm_source=default",
      "name": "GoodGym",
      "telephone": "0203 432 3920",
      "email": "[email protected]",
      "logo": {
        "@type": "ImageObject",
        "url": "https://www.goodgym.org/assets/goodgym_red-688adde9f7d011eb16c0cafa461d8f214e93fdefe2044d10f6cf68fee52c1584.png"
      }
    },
    "name": "Hill Session with Tom",
    "identifier": 616,
    "id": "http://www.goodgym.org/api/happenings/hill-session-with-tom",
    "url": "http://www.goodgym.org/happenings/hill-session-with-tom?utm_medium=openactive&utm_source=default",
    "description": "Come along for a challenging but rewarding interval session with Tom!\nAfter a warm up and running drills we'll be getting stuck into sets or short, fast hills that help develop speed and power, mixing these with race effort running. Come along, get fitter, simple!\nThe session is tough but reward to totally achievable FOR ALL ABILITIES!\nMeeting at Mile End Park, at the base of the Green Bridge at the southern end.\n",
    "beta:formattedDescription": "Come along for a challenging but rewarding interval session with Tom!\r\n\r\nAfter a warm up and running drills we'll be getting stuck into sets or short, fast hills that help develop speed and power, mixing these with race effort running. Come along, get fitter, simple!\r\n\r\nThe session is tough but reward to totally achievable FOR ALL ABILITIES!\r\n\r\nMeeting at Mile End Park, at the base of the Green Bridge at the southern end.",
    "disambiguatingDescription": "A short, but tough session for speed and power",
    "activity": [{
      "@type": "Concept",
      "prefLabel": "Running"
    }],
    "programme": {
      "@type": "Brand",
      "name": "Training Session"
    },
    "startDate": "2014-09-23T18:45:00+01:00",
    "endDate": "2014-09-23T20:40:00+01:00",
    "duration": "PT115M",
    "location": {
      "type": "Place",
      "address": {
        "type": "PostalAddress",
        "streetAddress": "Mile End Park ",
        "addressLocality": "London",
        "postalCode": "E3 4PL"
      },
      "geo": {
        "type": "GeoCoordinates",
        "latitude": 51.52462,
        "longitude": -0.0354348
      },
    },
    "remainingAttendeeCapacity": 22,
    "maximumAttendeeCapacity": 25,
    "beta:distance": {
      "value": 6,
      "unit": "KMT"
    },
    "beta:level": "intermediate",
    "beta:hasCoaching": false,
    "beta:registrationCount": 3,
    "ageRange": "18",
    "genderRestriction": "mixed",
    "isAccessibleForFree": true,
    "publicAccess": true,
    "beta:orderPostUrl": "http://www.goodgym.org/api/external_registrations",
    "offers": {
      "type": "Offer",
      "id": "http://www.goodgym.org/api/happenings/hill-session-with-tom#offer",
      "price": "0"
    },
    "invalidAtrribute": {
      "toLocation": [],
      "areaServed": null
    }
  }
}

Clone this wiki locally