def parse_path(path):
    """
    http://www.w3.org/TR/2014/WD-html-json-forms-20140529/#dfn-steps-to-parse-a-json-encoding-path
    """
    original = path
    failure = [(original, {'last': True, 'type': object})]
    steps = []
    try:
        first_key = path[:path.index('[')]
        if not first_key:
            return original
        steps.append((first_key, {'type': 'object'}))
        path = path[path.index('['):]
    except ValueError:
        return failure
    while path:
        if path.startswith('[]'):
            steps[-1][1]['append'] = True
            path = path[2:]
            if path:
                return failure
        elif path[0] == '[':
            path = path[1:]
            try:
                key = path[:path.index(']')]
                path = path[path.index(']') + 1:]
            except ValueError:
                return failure
            try:
                steps.append((int(key), {'type': 'array'}))
            except ValueError:
                steps.append((key, {'type': 'object'}))
        else:
            return failure
    for i in range(len(steps) - 1):
        steps[i][1]['type'] = steps[i + 1][1]['type']
    steps[-1][1]['last'] = True
    return steps
