Search - User list
Full Version: Dictionary Expand
Root » PDG/TOPs » Dictionary Expand
Johan Boekhoven
I use url_request a lot and I was wondering if there was an easier way to expand a json/dict response to actual attributes.
Right now I have a python node where I just map it all manually, I was wondering if there was a easier way?
Johan Boekhoven
I solved it for now like so. I either need int or string so I limited the types to those two.

task_data = work_item.pyObjectAttribValue('task_data')[0]

for key in task_data.keys():
    attr_type = type(task_data[key]).__name__
    val = task_data[key]
    
    if attr_type == 'int':
        work_item.setIntAttrib(key, val)
    else:
        work_item.setStringAttrib(key, str(val))
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB