def extract_paths(thisjson, parent=[]):
    """
    Extracts all paths from a json with nested structures.
    You can use the resulting paths with get_json_path_element(j, path)
    to get all values from a nested json structure.
    E.g. running this function for the following json
    thisjson = {
        "key":"value",
        "dict":{
            "nested":"value"
        },
        "plainlist":[
            "value1",
            "value2"
        ],
        "nestedlist": [
            {
                "object":"value"
            },
            "value3"
        ]
    }

    will give ['nestedlist,0,object', 'dict,nested', 'plainlist', 'key']
    """
    attributes = []
    for key in thisjson.keys():
        val = thisjson[key]
        if isinstance(val, dict):
            attributes.extend(extract_paths(val, parent=parent+[key]))
        elif isinstance(val, list):
            has_dict = False
            for i, item in enumerate(val):
                if isinstance(item, dict):
                    has_dict = True
                    attributes.extend(extract_paths(item, parent=parent+[key, str(i)]))
            if not has_dict:
                if parent:
                    attributes.append(','.join(parent)+','+key)
                else:
                    attributes.append(key)
        else:
            if parent:
                attributes.append(','.join(parent)+','+key)
            else:
                attributes.append(key)
    return attributes