Not sure if I understood your question corrently, but (having already made a long reply, getting deleted by "You cannot include external links with this low karma" <insert cursing>, I'll make it short)
All the function and methods used in your code snippet are from Python's built-in functions and types' methods. None of them are from Splunk's Python SDK.
For reference, see:
https://docs.python.org/2/library/functions.html (getattr(), enumerate(), str())
https://docs.python.org/2/library/stdtypes.html#dict.get
As for how to form a more complex JSON object; you do exactly similar dictionary & list processing.
JSON.dumps() converts python dictionaries { } to JSON objects, and python lists [ ] to JSON arrays.
See https://docs.python.org/2/library/json.html#encoders-and-decoders for full details on how default JSON encoder/decoder works.
... View more