Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pinbraerts/rekson
A simple standalone to rectify json
https://github.com/pinbraerts/rekson
fix-json json recover-json rectify-json rust
Last synced: 15 days ago
JSON representation
A simple standalone to rectify json
- Host: GitHub
- URL: https://github.com/pinbraerts/rekson
- Owner: pinbraerts
- License: mit
- Created: 2024-11-03T17:58:18.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-12-15T13:15:32.000Z (about 1 month ago)
- Last Synced: 2024-12-15T13:41:51.039Z (about 1 month ago)
- Topics: fix-json, json, recover-json, rectify-json, rust
- Language: Rust
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ⚡ rekson
rectify your json## 🍎 Motivation
I frequently edit [json](https://json.org) files.
It is a completely unusable configuration language with poorly written grammar.
So I came up with a simple program to fix manually edited json.
This is not a formatter, rather it is intended to be used in conjunction with one,
for example [`jq`](https://github.com/jqlang/jq).## ✨ Features
- [x] trailing comma (`{,"a":3,} -> {"a":3}`)
- [x] comma between values (`[1 2] -> [1, 2]`)
- [x] correct quotes (```{`key`: 'value'} -> {"key": "value"}```)
- [x] multiline strings
- [x] correct booleans (`True -> true`)
- [x] correct nulls (`None -> null`)
- [x] quote unknown values (`{a:3} -> {"a":3}`)
- [x] correct colon (`{"a"=3} -> {"a":3}`)
- [x] insert colon (`{b 4} -> {"b":4}`)
- [x] fix brackets (`{[{[{]] -> {[{[{}]}]}`)
- [x] replace parenthesis with brackets (`((),()) -> [[],[]]`)
- [x] async io## 💡 Plans
- [ ] strip comments
- [ ] convert numbers (`0xff -> 256`)
- [ ] COW (reduce memory copying)
- [ ] multithreading## ✅ Pros
- written in Rust => instant format on write
- no dependencies => faster to build than to install an npm package
- can be used as standalone executable
- can be used as standalone library## ❌ Cons
- barebone simplicity => adding new features requires rethinking the architecture
- single-threaded (for now)
- no configuration (for now)
- small testsuite (for now)## 🚀 Installation
### [crates.io](https://crates.io/crates/rekson)
```bash
cargo install rekson
```### From [source](https://github.com/pinbraerts/rekson)
```bash
cargo install --git https://github.com/pinbraerts/rekson
```### Binary
Prebuilt binaries can be found at the [releases](https://github.com/pinbraerts/rekson/releases) page.## 🛠️ Usage
Pass dirty json to stdin, receive fixed json in stdout.
### [conform.nvim](https://github.com/stevearc/conform.nvim)
```lua
require("conform").setup({
formatters = {
rekson = {
command = "rekson",
},
},
formatters_by_ft = {
json = { "rekson" },
})
})
```## 👀 Alternatives
- https://github.com/adhocore/php-json-fixer
- https://github.com/rhysd/fixjson
- https://github.com/Berkmann18/json-fixer
- https://github.com/messense/dirty-json-rs