const dirtyValue = [{"id":1,"name":"Проект1","parent":null,
"children":[{"id":3,"name":"Задача1.1","parent":1,
"children":[ {"id":2,"name":"Задача 1_1_1","parent":3,"children":[]},
{"id":8,"name":"Задача 1_1_2","parent":3, "children":[]}
]}]}];
const formatJson = item => {
const result = { ...item, Rec: { children: item?.children?.map?.(formatJson) } };
delete result?.children;
return result;
};
const value = dirtyValue.map(formatJson);
console.log(value);