I have a List<String> where each element represents a node and a String which is the value that corresponds to the last node of that list. The list represents the path to the value. So, basically each element of the list is the value of the previous element. I would like to create a JSON object from it using Jackson. However, this needs to be done dynamically, not explicitly setting the nodes of the JSON object, because the list will not always be the same.
So, I am wondering if there is a way to convert or iterate through the list and create the JSON object. So, if my list looks like this:
["user", "car", "brand"] and the value is "BMW", the JSON object should look like this:
{
"user":
{
"car":
{
"brand": "BMW"
}
}
}