rekson

Crates.iorekson
lib.rsrekson
version0.0.2
created_at2024-11-09 12:57:26.998235+00
updated_at2024-12-06 15:08:27.841792+00
descriptionA simple standalone to rectify json
homepagehttps://github.com/pinbraerts/rekson
repositoryhttps://github.com/pinbraerts/rekson
max_upload_size
id1442059
size19,006
Dmitry (pinbraerts)

documentation

README

⚡ rekson

rectify your json

🍎 Motivation

I frequently edit json 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.

✨ Features

  • trailing comma ({,"a":3,} -> {"a":3})
  • comma between values ([1 2] -> [1, 2])
  • correct quotes ({`key`: 'value'} -> {"key": "value"})
  • multiline strings
  • correct booleans (True -> true)
  • correct nulls (None -> null)
  • quote unknown values ({a:3} -> {"a":3})
  • correct colon ({"a"=3} -> {"a":3})
  • insert colon ({b 4} -> {"b":4})
  • fix brackets ({[{[{]] -> {[{[{}]}]})
  • replace parenthesis with brackets (((),()) -> [[],[]])
  • 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

cargo install rekson

From source

cargo install --git https://github.com/pinbraerts/rekson

Binary

Prebuilt binaries can be found at the releases page.

🛠️ Usage

Pass dirty json to stdin, receive fixed json in stdout.

conform.nvim

require("conform").setup({
  formatters = {
    rekson = {
      command = "rekson",
    },
  },
  formatters_by_ft = {
    json = { "rekson" },
  })
})

👀 Alternatives

Commit count: 67

cargo fmt