Hi,
I have noticed that the API outputs invalid JSON data, when i say invalid i mean invalid in the context of the data being outputted, its only valid if you are happy with receiving data that should be numbers as strings.
The issue is that some of the JSON data which should be numbers is being sent by the API as strings, this is not the case for all of the data which i would expect to be numbers, just some of it.
Here is an example of numbers correctly outputted in JSON format:
http://json-schema.org/example1.html
For Users, the data type is correct for “permission_level” but incorrect for “opening_mileage” as it should be a number not a string, “0.0” quoted as seen below is a string representation.
The output needs to be like this: “opening_mileage”: 0.0,
“users”: [
{
“url”: “https://api.sandbox.freeagent.com/v2/users/1111”,
“first_name”: “joe”,
“last_name”: “bloggs”,
“email”: "gfgdfgf@fgdgdfgfgdfg.co.uk",
“role”: “Director”,
“permission_level”: 8,
“opening_mileage”: “0.0”,
“updated_at”: “2017-04-04T00:00:43.000Z”,
“created_at”: “2016-12-09T00:00:31.000Z”
},
…
For Timeslips, “hours” should be a number not a string, “7.0” quoted is a string is a string representation.
The output needs to be like this: “hours”: 7.0,
“timeslips”: [
{
“url”: “https://api.sandbox.freeagent.com/v2/timeslips/1111”,
“user”: “https://api.sandbox.freeagent.com/v2/users/1111”,
“project”: “https://api.sandbox.freeagent.com/v2/projects/1111”,
“task”: “https://api.sandbox.freeagent.com/v2/tasks/1111”,
“dated_on”: “2017-03-20”,
“hours”: “7.0”,
“updated_at”: “2017-03-22T13:00:15.000Z”,
“created_at”: “2017-03-22T13:00:15.000Z”
},
…
For Tasks, “billing_rate” should be a number not a string
It seems that booleans are correct from what i have seen so far.
“tasks”: [
{
“url”: “https://api.sandbox.freeagent.com/v2/tasks/1111”,
“project”: “https://api.sandbox.freeagent.com/v2/projects/1111”,
“name”: “Design”,
“is_billable”: true,
“billing_rate”: “5.0”,
“billing_period”: “hour”,
“status”: “Active”,
“created_at”: “2016-12-09T00:58:32.000Z”,
“updated_at”: “2016-12-09T00:58:32.000Z”
},
For Projects, “normal_billing_rate” and “hours_per_day” should be a number not a string
“budget” is correct
“project”: {
“url”: “https://api.sandbox.freeagent.com/v2/projects/1111”,
“name”: “Project 1”,
“contact”: “https://api.sandbox.freeagent.com/v2/contacts/1111”,
“currency”: “GBP”,
“created_at”: “2016-12-09T00:53:02.000Z”,
“updated_at”: “2017-03-22T00:28:48.000Z”,
“starts_on”: “2016-12-01”,
“ends_on”: “2017-03-23”,
“budget”: 80,
“is_ir35”: false,
“contract_po_reference”: “00111”,
“status”: “Active”,
“budget_units”: “Hours”,
“normal_billing_rate”: “5.0”,
“hours_per_day”: “7.5”,
“uses_project_invoice_sequence”: false,
“billing_period”: “hour”
}
}
As can be seen the output is not consistent and caused a moment of “what the heck” when first discovered, for now i am patching the output to convert the strings to numbers.
There may be other examples but those listed are what i have found so far.
From what i have seen so far, the issue seems to be with floating point numbers, i don’t know what JSON serializer you are using but it doesn’t seem to be standards based.
Thanks,
Chris