ljharb / ljharb/json-stable-stringify

key alignment option?

Open
#2 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
79
Forks
18
PR merge metrics
No merged PRs in 30d

Description

I would really like to see a new option that aligns the keys for even more readability when pretty printing... e.g.

```js
stringify({"a": 5, "foo": true, "glue": "hello"}, {space: ' ', alignKeys: true});
```

produces something like
```
{
"a" : 5,
"foo" : true,
"glue" : "hello"
}
```
Should be an easy option to add. Maybe I'll submit a PR if I get less lazy...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the stringify entry point and inspect how the space option formats object keys. Add coverage for the alignKeys option using the example object and expected aligned output, then verify existing formatting remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.