Question: I'd like to send request using python and requests library. 
I have checked this request in web browser inspector and form data looks like that:

```
data[foo]: bar
data[numbers][]: 1
data[numbers][]: 2
data[numbers][]: 3
data[numbers][]: 4
data[numbers][]: 5
csrf_hash: 12345

```

This is my code:

```
payload = {'data[foo]': 'bar', 'csrf_hash': 12345,
         'data[numbers]': [1, 2, 3, 4, 5]}
r = s.post('https://www.foo.com/bar/', payload)

```

It doesn't work. I'm getting error because of invalid post data

Answer: 
I needed a way to deal with it in a more dynamic / adaptable way. What I came up with was this:

```
def multi_dict_to_php_dict(md):
    result = {}
    for key in md.keys():
        if '[]' in key:  # Key is an array, we need to make the array keys unique.
            keyformat = '[%d]'.join(key.split('[]'))
            for idx, val in enumerate(md.getlist(key)):
                result[keyformat % idx] = val
        else:  # Key is just a value, include it in the new result.
            result[key] = md[key]
    return result

```

This supports things like `number[]`, as well as `group[][name]` (what I was encountering) or `item[children][]`. It wouldn't (in its current form) handle `arrayofarrays[][]`, but it could probably be made to with some minor adaptation.
Can you try to do this:

```
import json

url = 'https://www.foo.com/bar/'
payload = {'some': 'data'}

r = requests.post(url, data=json.dumps(payload))

```