Json2dir
Convert JSON object to directory tree. Auto mkdir recursively.
Install / Use
/learn @chientrm/Json2dirREADME
json2dir
- Convert JSON object to directory tree
- Auto
mkdirrecursively - 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
node-connect
354.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
