AskJS
The problem was to convert a flat object with dot-separated keys into a properly nested object/array structure.
Example
Input
const input = {
name: 'Saksham',
'skills.domain.fe.0': 'React',
'skills.domain.fe.1': 'Next.js',
'skills.domain.be.0': 'Node',
'skills.domain.be.1': 'Express',
'skills.experience': 3,
'projects.0.title': 'FitConnect',
'projects.0.tech.frontend': 'React',
'projects.0.tech.backend': 'Node'
};Expected Output
{
name: "Saksham",
skills: {
domain: {
fe: ["React", "Next.js"],
be: ["Node", "Express"]
},
experience: 3
},
projects: [
{
title: "FitConnect",
tech: {
frontend: "React",
backend: "Node"
}
}
]
}