Indentation size and sorting
kseistrup opened this issue · 2 comments
kseistrup commented
Perhaps it would be useful with two optional parameters: sort (boolean) and indent (integer or string).
A version of the example with indentation=2 and sorted keys could look like this:
{
"age": 37,
"children": [
"Sara",
"Alex",
"Jack"
],
"fav.movie": "Deer Hunter",
"friends": [
{
"age": 44,
"first": "Janet",
"last": "Murphy"
}
],
"name": {
"first": "Tom",
"last": "Anderson"
}
}
tidwall commented
Thanks for the suggestion. Sorting would be a nice option.
Right now there's a PrettyOptions(json, opt)
function that allows for providing the indentation and also the max-width for single line arrays.
tidwall commented
I just pushed an update that allows for sorting keys on objects.