I want to create JSON using java properties using js.
input
a[1][1]=d
output should be
{ a: [ null, [ null, "d" ] ] }
I found a workaround. first I extract all the indexes and pass it to recursive function
const arrayRecursiveFn = function (indexes, value, result) {
let index = indexes[0];
if (indexes.length === 1) {
result[index] = value;
} else {
let obj = [];
result[index] = arrayRecursiveFn(indexes.slice(1), value, obj);
}
return result;
}
const op = arrayRecursiveFn([1,1],0 , [])
console.log("op",op)
full implementation https://github.com/mehimanshupatil/propertiesToJSON