const jsonfile = require('jsonfile');
const path = require('path');

const data = jsonfile.readFileSync(path.join(__dirname, './input.json')).map((item) => {
  return {
    tree: item.path.map((value) => value.category_name).join(' > '),
    name: item.category_name,
    id: item.category_id,
    image: item.images[0],
  };
});

jsonfile.writeFileSync(path.join(__dirname, './output.json'), data);
