Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API doesn't support non-numeric IDs #1

Open
carlson opened this issue Nov 3, 2011 · 4 comments
Open

API doesn't support non-numeric IDs #1

carlson opened this issue Nov 3, 2011 · 4 comments

Comments

@carlson
Copy link

carlson commented Nov 3, 2011

The API represents ids as JSON numbers:

"id":999,
"service_id": 2

Is it the spec's intention that ids must be numbers? Some systems use GUIDs instead. The spec could handle this by treating ids as strings:

"id": "999"

or

"id": "4e8d861757bb9cf10b21c115"

@straup
Copy link
Owner

straup commented Nov 3, 2011

The spec as it currently written is agnostic on whether IDs should be numbers or strings. Requiring one over the other is probably just a recipe for annoying people :D

So yes: That should be cleared up, probably in api.md

Thanks!

@carlson
Copy link
Author

carlson commented Nov 3, 2011

OK, if left agnostic consumers of the API will need to handle ids with JSON data types that may vary across implementations. For example (in Java): String id = json.getString("id"); or int id json.getInt("id"); depending on the server's implementation. This is less of an issue in dynamically typed languages. Cheers.

@straup
Copy link
Owner

straup commented Nov 3, 2011

Yeah, it's not awesome. I've updated the spec to say that it probably means that clients will need to assume everything is a string.

I'm willing to be convinced otherwise but it seems easier to put that burden on clients rather than the technical infrastructure of any given city.

UIDs as strings will eventually incur a not insignificant cost in database indexes for a city with lots of records.

@carlson
Copy link
Author

carlson commented Nov 3, 2011

Right, was never suggesting the API should (or could) dictate what type of ids the server implementation uses, only which JSON data type (string or number or either) will be used when transferring ids between client & server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants