json-to-yaml Convert JSON to YAML
Flags
--indent number default: 2
Examples
Convert a JSON object to YAML
Usage
"{"name":"Alice","age":30,"roles":["admin","editor"]}" | json-to-yaml Convert a Docker config from JSON to YAML for Compose
Usage
"{"image":"nginx:latest","ports":[{"containerPort":80}],"env"..." | json-to-yaml Convert application settings from JSON to human-friendly YAML
Usage
"{"title":"My App","version":"1.0","settings":{"debug":false,..." | json-to-yaml View source
async (input, opts = {})=>{
try {
const yaml = await import('js-yaml').then(async (m)=>{
await m.__tla;
return m;
});
return yaml.dump(JSON.parse(input), {
indent: parseInt(opts.indent) || 2
});
} catch (e) {
return `Error: ${e.message}`;
}
}