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

Numbers as keys #54

Closed
ivan-krukov opened this issue Apr 6, 2015 · 2 comments
Closed

Numbers as keys #54

ivan-krukov opened this issue Apr 6, 2015 · 2 comments
Labels
kind: enhancement/improvement solution: invalid the issue is not related to the library

Comments

@ivan-krukov
Copy link

I know this isn't strictly json-compliant, but I would love to have numbers as keys.

Say I try:

std::map data<double, double> = {{1.0, 2.0}, {3.0, 4.0}};

I would like to be able to:

json j_data(data);

In order to get:

{1.0:2.0, 3.0:4.0}

I think the strength of json is that it can take a little bit of abuse.
Thanks.

@nlohmann
Copy link
Owner

nlohmann commented Apr 8, 2015

Dear @ivan-kryukov, thank you for your proposal. As such an extension would not be JSON compliant, it would be out of scope of this library. I understand that there is a use case for anything thinkable, but I am afraid I would make my code less predictable and maintainable when I would leave the constraints of JSON.

@nlohmann nlohmann closed this as completed Apr 8, 2015
@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Apr 8, 2015
@ivan-krukov
Copy link
Author

Fair enough. Thanks for the great library. I hope it will be pulled into the standard C++ library at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement/improvement solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants