Closed antigravities closed 3 years ago
I think the 0-key object is annoying to deal with. I'd rather just remove it.
The API should return an an object with with a key
0
if the profile has not sent or received any offers.
Researching...
Knowledge Acquired https://stackoverflow.com/questions/15290811/php-json-encode-issue-with-array-0-key
$result = json_encode($array, JSON_FORCE_OBJECT);
Result https://barter.vg/u/6f75/o/json
{"0":{"count":0}}
I think the 0-key object is annoying to deal with. I'd rather just remove it.
Yes, in hindsight, this decision doesn't make much sense. I'll remember it for JSON feed 2.0.
I think the 0-key object is annoying to deal with. I'd rather just remove it.
I was just aiming for consistency. Breaking changes should be part of a 2.0.
Describe the bug
Profiles that have not sent or received offers return an array of an object through the API endpoint
/u/hexID/o/json
, as opposed to an object with with just a key0
. This edge case causes potential issues with parsing the response from endpoint as the returned objects are fundamentally different.Here is a profile that contains zero offers (at time of writing), as opposed to a profile that contains one or more offers.
Expected behavior
The API should return an an object with with a key
0
if the profile has not sent or received any offers.