#json #fix-json #dirty-json #bad-json

app rekson

A simple standalone to rectify json

1 unstable release

new 0.0.1 Nov 9, 2024

#1354 in #json

MIT license

16KB
403 lines

🛠️ 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)

👀 Alternatives

No runtime deps