I have an input json like:
{
    "Employee": [
      {
        "employee1.id": 1
      },
      {
        "employee1.name": "John"
      },
      {
        "employee1.address.street": "main street"
      },
      {
        "employee1.address.pin": "123456"
      },
      {
        "employee2.id": 2
      },
      {
        "employee2.name": "Mike"
      },
      {
        "employee2.address.street": "51 street"
      },
      {
        "employee2.address.pin": "234543"
      }
    ]
}
And I am trying to convert it into:
{
    "employee1":{
        "id": 1,
        "name": "John",
        "address": {
            "street": "main street",
            "pin": "123456"
        }
    },
        "employee2":{
        "id": 2,
        "name": "Mike",
        "address": {
            "street": "51 street",
            "pin": "234543"
        }
    }
}
I tried to split the key from input json with dot i.e. '.' and tried to iterate over to construct a map: Map<String, Object> But the problem is the input json key depth can go beyond 2 i.e. in future the input key can be like:
{
    "employee1.address.tempAddress.street": "main street"
},
{
    "employee1.address.permanentAddress.street": "main street"
}
So, is there any library available to achieve this, or anything closely related to this using which I can achieve this?
 
     
    