How can I convert protobuff “map” type to object?

I have a next proto type:

message Test {
    map <string, string> values = 1;
}

Next, I’m making an object of this type:

const test = new Test().getValuesMap().set("test", "1")

And then, I’m trying to lead this type to an object:

console.log(JSON.stringify(test.toObject(), null, 4));

So, I’m getting this structure:

{
    valuesMap: [
        ["test", "1"]
    ]
}

But I’m expecting a structure like this:

{
    values: {
        test: "1"
    }
}

According to this file, the behaviour with “valuesMap” is valid. However, is there any way to convert a proto to an object as I’m expecting?

Also, the provided example is synthetic. In real case I have a recursive structure like this:

{
    "root": {
        "valuesMap": [
            [
                "key1",
                {
                    "name": "some-name"
                    "nested": {
                        "valuesMap": [
                            [
                                "key2",
                                {
                                    "name": "other-name"
...

So instead of using just res.toObject(), I need to write some recursive function on a client to transform this object.