-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAge
Milestone
Description
If you call json.Marshal with a map, it sorts the keys. If you do a search, you will find a Stack Overflow page explaining this[1]. However, this behavior isn't mentioned in the godoc.
It's useful to assume that the emitted JSON will be deterministic, since then you can use string equality or compare hashes to look for duplicates and compare the emitted JSON to a golden copy in tests. But since this property isn't mentioned, it's unclear whether users can rely on the emitted JSON remaining the same in new versions of Go.
Many people will do it anyway, so perhaps we should make it official?
[1] http://stackoverflow.com/questions/18668652/how-to-produce-json-with-sorted-keys-in-go
bronze1man, asdine and sasounda
Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAge