Java: Object list to json string using name as key

I have an array list of objects that has multiple properties. I want to create a json string out of this array, where the "name" property of each object should be the key and every other property then listed as a key - value pair.

I know how to convert the array to a json string using the objectmapper from the jackson package, but i am unable to get the name property to be the key of each object, and then the remaining properties listed as key value pairs.

I mean to have the following structure:

     "name1" :   {
         "property1" : "value1",
         "property2" : "value2"
    "name2" : {
         "property1" : "value3",
         "property2" : "value4"

And so on.