@visual-json/yaml
v0.4.0
Published
YAML support for visual-json — parse, serialize, and schema-detect YAML files.
Readme
@visual-json/yaml
YAML support for visual-json — the visual JSON editor.
Parse and serialize YAML, convert between YAML and tree states, and detect schemas for well-known YAML files.
Install
npm install @visual-json/yaml @visual-json/coreUsage
import { fromYaml, toYaml, parseYamlContent, stringifyYamlContent } from "@visual-json/yaml";
// Parse YAML into a TreeState for use with visual-json components
const state = fromYaml(`
name: my-app
version: 1.0.0
scripts:
build: tsc
`);
// Convert a TreeState back to YAML
const yaml = toYaml(state);API
Schema Detection
The core resolveSchema function recognizes many popular YAML config files and automatically fetches the appropriate JSON Schema. This powers schema-aware editing in the VS Code extension for files like:
docker-compose.yml/docker-compose.yaml.github/workflows/*.yml.gitlab-ci.ymlpnpm-workspace.yamlserverless.yml/serverless.yaml.prettierrc.yml/.eslintrc.yml- And many more
See @visual-json/core schema docs for the full list.
License
Apache-2.0
