Where appropriate, the Cortex Data Lake REST API accepts and returns JSON payloads/responses, a format that pairs well with the Python programming language.
So you want to convert your JSON response into a python object? With
requests under the hood, it’s downright easy:
Let's take a look at the difference between
dictionary shall we?
raw (formatted for display):
What if you want to enforce proper JSON encoding on all responses?
Now, if a response returns something not JSON-serializable, the CDL Python SDK will raise a
CortexError that can be handled, appropriately, in your client code.
Looking for an easy, cheap way to boost your JSON encoder/decoder? Install
ujson and the CDL Python SDK will automatically use it in place of the standard library
Visit the UltraJSON GitHub Repo for more details on installation and usage.
So what's happening under the hood? Basically, something similar to this:
If you have debug logging enabled then you'll see the following message logged to your console: