def get_value_for_key_from_json(key, data_structure):
    """
    Given a data_structure return the *first* value of the key from the first dict
    example:
        data_structure: [ { "id": 1, "name": "name1" }, { "id": 2, "name": "name2"} ]
        key: "id"
        return 1

    :param key: key of a dict of which to return the value
    :param data_structure: python data_structure
    :return: value of key in first dict found
    """

    if type(data_structure) == list:
        for v in data_structure:
            # print("recursively searching %s" % str(v))
            r = get_value_for_key_from_json(key, v)
            if r is not None:
                return r

        return None

    elif type(data_structure) == dict:
        if key in data_structure:
            return data_structure[key]
        else:
            for k in data_structure:
                v = data_structure[k]
                # print("recursively searching %s" % str(v))
                r = get_value_for_key_from_json(key, v)
                if r is not None:
                    return r

    return None