I have a front-end application that sends a formData which contains arrays, so I'm using "object-to-formdata" to parse an the following object:

```
{
        "profileImage": {
            "name": "5574c060-853b-4999-ba39-1c66d5329704",
            "size": 364985,
            "mimetype": "image/png",
            "url": "uploads/5574c060-853b-4999-ba39-1c66d5329704"
        },
        "skills": [],
        "lessonsFinished": [],
        "classes": [],
        "_id": "5e3c2f8c80776b12cc336fdf",
        "email": "test@test.com",
        "password": "$2b$10$iZ3/BuklZ1FCGlyQDPUyMOhcWAfei5yl.llYScbWIv12XWcsokrgS",
        "username": "adrian",
        "verified": false,
        "status": "student",
        "color": "blue",
        "verificationCode": "50SZWPCHDL685C",
        "__v": 0,
        "lastName": "Test",
        "name": "Test",
    }

```

The object contains objects and arrays, and when parsed and sent to the backend, which uses express, with bodyParser and "express-fileupload" as a file manager, I receive this object:

```
{
    'profileImage[name]': '5574c060-853b-4999-ba39-1c66d5329704',   
    'profileImage[size]': '364985',
    'profileImage[mimetype]': 'image/png',
    'profileImage[url]': 'uploads/5574c060-853b-4999-ba39-1c66d5329704',
    'skills[]': '',
    'lessonsFinished[]': '',
    'classes[]': '',
    _id: '5e3c2f8c80776b12cc336fdf',
    email: 'test@test.com',
    password: '$2b$10$iZ3/BuklZ1FCGlyQDPUyMOhcWAfei5yl.llYScbWIv12XWcsokrgS',
    username: 'adrian',
    verified: 'false',
    status: 'student',
    color: 'blue',
    verificationCode: '50SZWPCHDL685C',
    __v: '0',
    lastName: 'Test',
    name: 'Test',
  }

```

I cannot seem to find a way of parsing this into a normal Object, since I need to use the full object as a query parameter for mongoose.

My Express configuration goes as follows:

```
const bodyParser = require('body-parser');
const fileUpload = require('express-fileupload');
const express = require('express');

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(fileUpload())

```

Finally, I have the endpoint in which I am receiving the formData:

```
exports.create = function (model) {
    return async function (req, res, next) {
        try {
            let document = req.body;
            if (req.files) {
                Object.keys(req.files).forEach(key => {
                    let file = req.files[key]
                    file.mv(upload_dir + file.name, (err) => {
                        if (err) return res.status(500).send(err);
                    });
                    document[key] = {
                        name: file.name,
                        size: file.size,
                        mimetype: file.mimetype,
                        url: upload_dir + file.name
                    }
                })
            }
            const newDocument = await new model(req.body).save();
            res.status(200).send(newDocument);
        } catch (err) {
            return next({
                status: 500,
                message: err.message
            })
        }
    }
}

```

I receive the file just fine, and the rest of the data as well, but i cannot find a way of parsing the "encoded" (as in surrounded by brackets) object keys.
I tried building a recursive function to decode them but after several hours I couldn't find a solution and I figured there must be another way already working.

I tried the solutions presented in this thread: [How to convert FormData(HTML5 Object) to JSON](https://stackoverflow.com/questions/41431322/how-to-convert-formdatahtml5-object-to-json) but those just create an Object with the brackets included in the key...

Thank you in advance for the help!
['https://Stackoverflow.com/questions/60176340', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11101440/']
If you have a small program that is going to exit quickly and you are running on a fully-featured modern desktop or server operating system, then probably you can rely on the operating system to clean up allocated heap memory when the process terminates; see [here](https://stackoverflow.com/questions/15882531/does-the-heap-get-freed-when-the-program-exits).

Unless rsprintf\_s specifically tells you that you should free what it returns, I would not assume this is the case. It is possible that it has an implementation which does not even use heap memory (perhaps it uses statically allocated global memory, perhaps in a DATA section or something).
If you are on an operating system, where a misbehaving process can't really do much passive harm, then it is in practice fine. Active harm such as corrupting files is another thing, but leaving memory un-freed at program exit will not interact with those system APIs. So omitting memory free at program exit is, in a sense, always fine when program is running in such an operating system (such as any modern desktop OS).

From a different viewpoint, it is never fine. The reasons why include, from the top of my head:

* It's just not very smart to intentionally write non-portable code, when you don't *have to* for some reason. You never know what future brings.
* Being sloppy with memory while not being sloppy with other things, that's a difficult mindset to maintain. Just don't be sloppy with your code.
* What is now program exit might end up being just error handling function and resuming normal operation later, and then first of all it's easy to forget to fix the memory leak, and further you may have to do a lot of refactoring, when you suddenly need to have access to the pointer to be freed in a place where previously you had just thrown it away already.
* When they see leaks, other programmers will think poorly of the whole program, and as an extension, of the programmer who wrote it.
* In other languages, such as C++, freeing memory is coupled with calling cleanup code such as class destructor, and those in turn may for example flush buffers and close files, and not doing that can leave corrupt files etc. Better not develop bad habits with C, which you'd need to unlearn with different language.