Dictionary Expand

   921   1   1
User Avatar
Member
72 posts
Joined:
Offline
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?
User Avatar
Member
72 posts
Joined:
Offline
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))
  • Quick Links