I have a sorted list (by key) of key value pairs like this:
administration.edit.error.type1 = val1
administration.edit.error.type2 = val2
administration.edit.success.type1 = val3
administration.label.button.close = val4
administration.label.button.edit = val5
home.label.button.open = val6
I would want to convert this list to
{
"administration": {
"edit": {
"error": {
"type1": val1,
"type2": val2,
},
"success": {
"type1": val3
}
},
"label": {
"button": {
"close": val4,
"edit": val5,
}
}
},
"home": {
"label": {
"button": {
"open": val6
}
}
}
}
The provided input list is unknown, as well as the levels connected by the dots
My approach would have been to recursively, iterate through the list and create JsonNodes with Jackson mapper. Is there a more efficient way to do this? Is there maybe a library that can already do this?