You certainly can, as long as you are 100% sure that all your API calls will only return a JSON object, not a number, string, boolean, or null. Since JSON supports all those types, one cannot be assured that only a JSON object (the equivalent of a Python dict) will be returned.
I know of several APIs that may return an array instead of just an object, so I would be somewhat concerned with this approach. But if you know or control the endpoints and return values, then you can define this how you would like.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You certainly can, as long as you are 100% sure that all your API calls will only return a JSON object, not a number, string, boolean, or
null
. Since JSON supports all those types, one cannot be assured that only a JSON object (the equivalent of a Pythondict
) will be returned.I know of several APIs that may return an array instead of just an object, so I would be somewhat concerned with this approach. But if you know or control the endpoints and return values, then you can define this how you would like.