Skip to content

Missing documentation with regards to sorted output #1015

Open
@bcc32

Description

@bcc32

I found this behavior surprising: for a Serializable value t, the following prints a JSON object with all keys sorted lexicographically:

serde_json::to_writer_pretty(std::io::stdout(), &serde_json::to_value(t)?)?;

On the other hand, the following prints the same value without sorting:

serde_json::to_writer_pretty(std::io::stdout(), t)?;

Of course, if you know how the underlying implementation works, this isn't actually that surprising, but I didn't actually see anywhere where this difference was documented, nor does the documentation of Value mention that it does have the sorting behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions