ljharb / json-stable-stringify

MIT License
55 stars 11 forks source link

add key path param #1

Open maa-dar opened 1 year ago

maa-dar commented 1 year ago

add key path to parameters sent to compare and replacer as this info is sometimes very crutial.

Why?

Often one would like to customize the printing of json based on where the json is in the tree like for example take:

{
  users: [
    {id:5. name: 'john', familyName: 'doe'}, ...
  ],
  asset: [
    {id:5, family: 'tools', name: 'hammer' }, ...
  ]
}

so here the family of the asset i want it before the name while in the user i want the family name to be before. (Note this is a theoratical example just to better explain my point)