SkillAgentSearch skills...

Json2dir

Convert JSON object to directory tree. Auto mkdir recursively.

Install / Use

/learn @chientrm/Json2dir
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

json2dir

CI Codacy Badge Codacy Badge

  • Convert JSON object to directory tree
  • Auto mkdir recursively
  • Zero dependencies
  • Lightweight ~1 KB

Install

npm install json2dir

Types

json2dir(
    dir: string,
    serializers: Record<string, (obj: any) => string>,
    obj: any
) : void

Usage

import json2dir from 'json2dir'
import ini from 'ini'

const bob = { name: 'Bob', age: 23 }

json2dir(
    '/root',
    {
        '.ini': ini.encode,
        '.json': JSON.stringify
    },
    {
        'a.json': bob,
        'b.ini': { INFO: bob },
        c: { d: { 'e.json': bob } },
        '.sub/foo.bar/f.json': bob
    }
)

Results

/root
│   a.json
│   b.json
│
└───c/d
│   │
│   │   e.json
│
└───.sub/foo.bar
    │
    │   f.json

Exceptions

If serializer is not provided, an exception will occur. For example: Error: No serializer for extension '.json'

Sponsor

<img src="https://www.gitpod.io/svg/media-kit/logo-light-theme.svg" width="200"> <img src="https://upload.wikimedia.org/wikipedia/commons/1/1b/Svelte_Logo.svg" width="50">

<a href="https://www.buymeacoffee.com/chientrm" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60" width="217"></a>

Related Skills

View on GitHub
GitHub Stars4
CategoryDevelopment
Updated3y ago
Forks0

Languages

JavaScript

Security Score

60/100

Audited on Aug 15, 2022

No findings