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

JSONObject should maintain keys insert-order #210

Closed
ArifChishti opened this issue Mar 22, 2016 · 3 comments
Closed

JSONObject should maintain keys insert-order #210

ArifChishti opened this issue Mar 22, 2016 · 3 comments

Comments

@ArifChishti
Copy link

It would be nice to preserve keys order.
I am using datatables in my project and I need to decide columns (and columns-order) on server side. DataTables renders columns in the order it receives column-keys. Currently, JSONObject does not preserve key-order. Will it be as simple as changing HashMap to LinkedHashMap in JSONObject.

@johnjaylward
Copy link
Contributor

JSON does not guarantee ordered keys. See the specifications referenced in the readme. You should open a bug with datatables to allow an ordered configuration using an array of key names or some such.

@johnjaylward
Copy link
Contributor

looking at the documentation it already supports this:
https://datatables.net/manual/ajax#Column-data-points

use the "columns" option

@ArifChishti
Copy link
Author

@johnjaylward You are right. Thank you for your recommendation of DataTables manual reference.

This feature is not valid according to JSON specifications.

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