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

Add a flag to prevent from fields reorder #60

Open
subchen opened this issue Jan 13, 2018 · 2 comments
Open

Add a flag to prevent from fields reorder #60

subchen opened this issue Jan 13, 2018 · 2 comments

Comments

@subchen
Copy link

subchen commented Jan 13, 2018

Current the fields of output struct is sorted, it is not good for me to advanced process.
If the fields order is same with original json format, it is more easy to use for me.

@ChimeraCoder
Copy link
Owner

Could you elaborate on the use case for preserving the order? Field names aren't quite like imports, but in Go, it's generally preferred to keep things in alphabetical order.

@subchen
Copy link
Author

subchen commented Feb 5, 2018

For example: I got a json from https://api.github.com/repos/ChimeraCoder/gojson

{
    "id": 7344683,
    "name": "gojson",
    "full_name": "ChimeraCoder/gojson",
    "owner": {
        "login": "ChimeraCoder",
        "id": 376414,
        "avatar_url": "https://avatars0.githubusercontent.com/u/376414?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/ChimeraCoder",
        "html_url": "https://github.com/ChimeraCoder",
        "followers_url": "https://api.github.com/users/ChimeraCoder/followers",
        "following_url": "https://api.github.com/users/ChimeraCoder/following{/other_user}",
        "gists_url": "https://api.github.com/users/ChimeraCoder/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/ChimeraCoder/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/ChimeraCoder/subscriptions",
        "organizations_url": "https://api.github.com/users/ChimeraCoder/orgs",
        "repos_url": "https://api.github.com/users/ChimeraCoder/repos",
        "events_url": "https://api.github.com/users/ChimeraCoder/events{/privacy}",
        "received_events_url": "https://api.github.com/users/ChimeraCoder/received_events",
        "type": "User",
        "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/ChimeraCoder/gojson",
    "description": "Automatically generate Go (golang) struct definitions from example JSON",
    "fork": false,
    "url": "https://api.github.com/repos/ChimeraCoder/gojson",
    "forks_url": "https://api.github.com/repos/ChimeraCoder/gojson/forks",
    "keys_url": "https://api.github.com/repos/ChimeraCoder/gojson/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/ChimeraCoder/gojson/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/ChimeraCoder/gojson/teams",
    "hooks_url": "https://api.github.com/repos/ChimeraCoder/gojson/hooks",
    "issue_events_url": "https://api.github.com/repos/ChimeraCoder/gojson/issues/events{/number}",
    "events_url": "https://api.github.com/repos/ChimeraCoder/gojson/events",
    "assignees_url": "https://api.github.com/repos/ChimeraCoder/gojson/assignees{/user}",
    "branches_url": "https://api.github.com/repos/ChimeraCoder/gojson/branches{/branch}",
    "tags_url": "https://api.github.com/repos/ChimeraCoder/gojson/tags",
    "blobs_url": "https://api.github.com/repos/ChimeraCoder/gojson/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/ChimeraCoder/gojson/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/ChimeraCoder/gojson/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/ChimeraCoder/gojson/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/ChimeraCoder/gojson/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/ChimeraCoder/gojson/languages",
    "stargazers_url": "https://api.github.com/repos/ChimeraCoder/gojson/stargazers",
    "contributors_url": "https://api.github.com/repos/ChimeraCoder/gojson/contributors",
    "subscribers_url": "https://api.github.com/repos/ChimeraCoder/gojson/subscribers",
    "subscription_url": "https://api.github.com/repos/ChimeraCoder/gojson/subscription",
    "commits_url": "https://api.github.com/repos/ChimeraCoder/gojson/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/ChimeraCoder/gojson/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/ChimeraCoder/gojson/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/ChimeraCoder/gojson/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/ChimeraCoder/gojson/contents/{+path}",
    "compare_url": "https://api.github.com/repos/ChimeraCoder/gojson/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/ChimeraCoder/gojson/merges",
    "archive_url": "https://api.github.com/repos/ChimeraCoder/gojson/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/ChimeraCoder/gojson/downloads",
    "issues_url": "https://api.github.com/repos/ChimeraCoder/gojson/issues{/number}",
    "pulls_url": "https://api.github.com/repos/ChimeraCoder/gojson/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/ChimeraCoder/gojson/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/ChimeraCoder/gojson/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/ChimeraCoder/gojson/labels{/name}",
    "releases_url": "https://api.github.com/repos/ChimeraCoder/gojson/releases{/id}",
    "deployments_url": "https://api.github.com/repos/ChimeraCoder/gojson/deployments",
    "created_at": "2012-12-27T19:10:50Z",
    "updated_at": "2018-02-04T16:46:09Z",
    "pushed_at": "2018-01-30T05:56:31Z",
    "git_url": "git://github.com/ChimeraCoder/gojson.git",
    "ssh_url": "git@github.com:ChimeraCoder/gojson.git",
    "clone_url": "https://github.com/ChimeraCoder/gojson.git",
    "svn_url": "https://github.com/ChimeraCoder/gojson",
    "homepage": "",
    "size": 209,
    "stargazers_count": 1581,
    "watchers_count": 1581,
    "language": "Go",
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 100,
    "mirror_url": null,
    "archived": false,
    "open_issues_count": 31,
    "license": {
        "key": "gpl-3.0",
        "name": "GNU General Public License v3.0",
        "spdx_id": "GPL-3.0",
        "url": "https://api.github.com/licenses/gpl-3.0"
    },
    "forks": 100,
    "open_issues": 31,
    "watchers": 1581,
    "default_branch": "master",
    "network_count": 100,
    "subscribers_count": 40
}

This json is bigger. It is also not in alphabetical order.

I can have a good view for field priority and similar fields in group.

I think the order in original json is valuable for us, we should follow them.

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