0

JSON.stringify does not maintain the order of the keys. So it seems like random result everytime.

var obj = { name: 'kumar', age: 28, location: 'delhi'}
console.log(JSON.stringify(obj))

It returns following in different time

 "{"name":"kumar","age":28,"location":"delhi"}"
 "{"age":28,"name":"kumar","location":"delhi"}"

How to return the same result everytime? is there any option to sort keys in the JSON string?

Fizer Khan
  • 88,237
  • 28
  • 143
  • 153

0 Answers0