Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Data are displayed partly sorted #49

Open
manitu-opensource opened this issue Nov 3, 2017 · 2 comments
Open

Bug: Data are displayed partly sorted #49

manitu-opensource opened this issue Nov 3, 2017 · 2 comments

Comments

@manitu-opensource
Copy link

Current version of jsonovich (Firefox current) makes input

{
    "2017": {
        "08": {
            "count": 23
        },
        "09": {
            "count": 21
        },
        "10": {
             count": 34
        }
    }
}

getting displayed as

{
    "2017": {
        "10": {
             count": 34
        },
        "08": {
            "count": 23
        },
        "09": {
            "count": 21
        }
    }
}
@welwood08
Copy link
Collaborator

Thanks for the bug report, I can reproduce.

Unfortunately this is to be expected for several reasons:

  1. "An object is an unordered collection of zero or more name/value pairs" according to the JSON RFC.
  2. The JSON string is parsed into a JavaScript object before formatting and the order of properties when iterating over JS objects was until recently unspecified. The ordering defined in ES2015 is not always insertion order but would by chance be what you expected in the above case.
  3. The formatter iterates over the object properties in a way that is still unspecified even in the latest ES2018 draft anyway.

I'm not sure if I should try to fix this since the JSON spec itself states that objects are unordered. It may be possible, but I'll have to assess the costs when I'm rewriting the formatter.

@welwood08
Copy link
Collaborator

Sorry for the noise, wrong issue number in commit message.

@welwood08 welwood08 reopened this Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants