TheAlphaSchoolSystemPTYLTD / api-introduction

A basic introduction to the TASS API's.
16 stars 10 forks source link

Return JSON values as appropriate types #9

Open jtc opened 4 years ago

jtc commented 4 years ago

I have noticed that if a value is numeric, <=2137483646, and contains no leading zeroes, the TASS APIs will return the JSON value as a number (i.e. no quotes) rather than a string. I have seen this in student-details, library-integration and employee-hr, but presume it is the case in all APIs...

This seems to go for all fields, even those you wouldn't expect a number in, e.g. surname.

This leads to the JSON data type for a particular value being variable, both between schools e.g. student_code may be a number at a school with codes from 10000 but a string with alphanumeric codes, and also even within the same response e.g. homePhone being a string when it starts with a 0 or contains text say (M), otherwise a number.

The mix of data types is inconvenient when programming against the APIs, as you need to convert the data type before working with it to ensure consistent results and prevent errors.

I would like to request that the TASS APIs return values as their appropriate type--string with quotes or number without--consistently, perhaps according to the data type of the database column. So say student_code, UD fields, work_phone should always be returned as strings, instead of sometimes strings, sometimes numbers. While year_grp would be a number as it can only ever be a number (the DB column is a smallint).