XYJson
A VS Code extension for mutual conversion between XML, JSON, and YAML formats.
Features
- Convert to JSON: Transform XML or YAML content to JSON format
- Convert to YAML: Transform JSON or XML content to YAML format
- Convert to XML: Transform JSON or YAML content to XML format
- Auto-detection: Automatically detects the input format based on content
- Error highlighting: Shows error location when conversion fails
Usage
- Open a file containing JSON, XML, or YAML content
- Right-click in the editor
- Select one of the conversion options:
- "XYJson: Convert to JSON"
- "XYJson: Convert to YAML"
- "XYJson: Convert to XML"
Via Command Palette
- Open a file containing JSON, XML, or YAML content
- Press
Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
- Type "XYJson" and select the desired conversion command
The extension automatically detects the input format:
- JSON: Content starting with
{ or [
- XML: Content starting with
<
- YAML: All other content (YAML is the most permissive format)
XML Handling
When working with XML:
- Attributes are prefixed with
@_ (e.g., @_id, @_class)
- Text nodes are represented as
#text
- Output is formatted with 2-space indentation
Development
Prerequisites
Setup
npm install
npm run compile
Running the Extension
- Open this project in VS Code
- Press
F5 to launch the Extension Development Host
- Open a JSON, XML, or YAML file and test the conversion commands
Packaging
npx vsce package
This creates a .vsix file that can be installed in VS Code.
License
MIT
| |