ClojureScript JSON to EDN Converter for VSCode
A Visual Studio Code extension written in ClojureScript that converts between JSON and Clojure EDN formats. Useful when working with RESTful APIs and without a REPL for conversion. https://marketplace.visualstudio.com/items?itemName=billhedworth.clj-vsc-formatter
Features
- Convert JSON to EDN: Transform JSON data into Clojure EDN format
- Convert EDN to JSON: Transform Clojure EDN back to JSON format
- Flatten: Compress EDN or JSON into a single line while preserving structure
- Preserves data structure and formatting
- Accessible through both Command Palette and editor context menu
- Graceful error handling:
- Clear error messages for invalid JSON/EDN input
- Handles invalid selections or editor states
Installation
- Install from VSCode Marketplace https://marketplace.visualstudio.com/items?itemName=billhedworth.clj-vsc-formatter
- Reload VSCode
Usage
The extension provides three main commands through both the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and the editor context menu under "EDN/JSON Convert":
JSON to EDN: Convert JSON data to EDN format
- Select JSON text in your editor
- Right-click to open the context menu
- Select "Convert JSON to EDN"
EDN to JSON: Convert EDN data to JSON format
- Select EDN text in your editor
- Right-click to open the context menu
- Select "Convert EDN to JSON"
Flatten: Compress EDN or JSON to a single line
- Select EDN or JSON text in your editor
- Right-click to open the context menu
- Select "Flatten EDN/JSON"
Examples:
- JSON to EDN conversion:
{"name": "example", "numbers": [1, 2, 3]}
Converts to:
{:name "example"
:numbers [1 2 3]}
- Flatten EDN/JSON:
{:name "example"
:numbers [1 2 3]}
Converts to:
{:name "example" :numbers [1 2 3]}
Prerequisites
Setup
- Clone the repository
- Install dependencies:
npm install
Development Commands
Packaging the Extension
To create a .vsix file for local installation:
Ensure you have built the extension:
npm run release
Package the extension:
npm run package
This will create a clj-vsc-formatter-[version].vsix
file in the root directory.
Local Installation
To install the packaged extension:
- Open VSCode
- Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
- Type "Install from VSIX" and select it
- Navigate to and select the generated .vsix file