openactive / implementation-tracker

Activation Issue Tracker for OpenActive Implementations
1 stars 2 forks source link

Do not include empty strings. If string is empty, do not include property. #220

Closed nickevansuk closed 5 years ago

nickevansuk commented 5 years ago

Issue

Do not include empty strings. If string is empty, do not include property.

Example

Not like this:

"address": {
  "type": "PostalAddress",
  "streetAddress": "Nottingham Road",
  "addressLocality": "Mansfield",
  "addressRegion": "",
  "postalCode": "NG18 4AE",
  "addressCountry": "GB"
},

Like this:

"address": {
  "type": "PostalAddress",
  "streetAddress": "Nottingham Road",
  "addressLocality": "Mansfield",
  "postalCode": "NG18 4AE",
  "addressCountry": "GB"
},

Please check this logic is applied to all properties

nickevansuk commented 5 years ago

There are still empty strings and empty arrays, e.g.:

"repeatFrequency": "", "addressRegion": "", "leader": "", "level": [], "attendeeInstructions": " ",

You most likely want to do the opposite (i.e. json_encode empty string to null) of something like this: https://gist.githubusercontent.com/tureki/7af3ea2554eba60c34c5/raw/b8c3c950a1262371c62ccdfeec58a4594419faed/json_encode-null-to-empty-string-2.php combined with something like this https://stackoverflow.com/questions/9150726/unset-inside-array-walk-recursive-not-working

You need to ensure that the whole JSON response is free of empty strings, empty arrays, and strings that contain only whitespace.

nickevansuk commented 5 years ago

Looks good!

In case it's helpful we've now put together a more complete example from the above

https://developer.openactive.io/publishing-data/data-feeds/implementing-rpde-feeds#php