(obj)
return attrs
the json objects look like this:
    {
    "objType": {
      "attributes": {
      ...
      }
    }
    It always has the attributes nested below the object type
    This helper provides a way of getting at the attributes
the json objects look like this:
    {
    "objType": {
      "attributes": {
      ...
      }
    }
    It always has the attributes nested below the object type
    This helper provides a way of getting at the attributes
the json objects look like this : { objType : { attributes : { ... } } It always has the attributes nested below the object type This helper provides a way of getting at the attributes
def get_attributes(obj):
    """
    the json objects look like this:
    {
    "objType": {
      "attributes": {
      ...
      }
    }
    It always has the attributes nested below the object type
    This helper provides a way of getting at the attributes
    """
    if not obj or type(obj) is not dict:
        return {}

    keys = list(obj.keys())
    if len(keys) > 0:
        key = keys[0]
    else:
        return {}
    key_obj = obj.get(key, {})
    if type(key_obj) is not dict:
        # if the object is not a dict
        # it is probably already scoped to attributes
        return obj
    if key != "attributes":
        attrs = key_obj.get('attributes')
        if type(attrs) is not dict:
            # if the attributes doesn't exist,
            # it is probably already scoped to attributes
            return obj
    else:
        # if the attributes exist, we return the value, except if it's not a dict type
        attrs = key_obj
        if type(attrs) is not dict:
            return obj

    return attrs
def get_attributes ( obj ) : if not obj or type ( obj ) is not dict : return { } keys = list ( obj . keys ( ) ) if len ( keys ) > 0 : key = keys [ 0 ] else : return { } key_obj = obj . get ( key , { } ) if type ( key_obj ) is not dict : # if the object is not a dict # it is probably already scoped to attributes return obj if key != "attributes" : attrs = key_obj . get ( 'attributes' ) if type ( attrs ) is not dict : # if the attributes doesn't exist, # it is probably already scoped to attributes return obj else : # if the attributes exist, we return the value, except if it's not a dict type attrs = key_obj if type ( attrs ) is not dict : return obj return attrs