function main(state) {
  let value = state.text;

  try {
    value = JSON.parse(value);
  } catch (e) {
    state.postError("Invalid JSON");
    return;
  }

  value = sort(value);

  state.text = JSON.stringify(value, null, 2);
}
{
    "api":1,
    "name":"Sort JSON",
    "description":"Sort JSON",
    "author":"MaDnh",
    "icon":"sort-characters",
    "tags":"json,sort"
  }