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

Followup: Allow any data type as key, Improvements #343

Closed
wants to merge 6 commits into from

Conversation

Bixilon
Copy link
Contributor

@Bixilon Bixilon commented Sep 6, 2021

Followup of #340

@Bixilon
Copy link
Contributor Author

Bixilon commented Nov 27, 2021

Any update to this?

@cedricbeust-okta
Copy link

Couple of thoughts:

  • If the PR says "Allows any data type as key", then the only changes should be to do that. This PR contains a lot of other stuff which, while useful, should be in a separate PR to keep the commit log clean and easier to revert.
  • What's gained by allowing any data types as keys?

@Bixilon Bixilon changed the title Followup: Allow any data type as key Followup: Allow any data type as key, Improvements Nov 27, 2021
@Bixilon
Copy link
Contributor Author

Bixilon commented Nov 27, 2021

I made seperate commits for everything, this is imho fine. Is it not?

Why?

As I already stated here, I am the developer of an applcaition that generates various data from minecraft. I am exporting this data into 2/3 formats. The first one is a binary format, comparable with nbt. This format allows numbers as key (json does not!). I also export it into json and minified json. JSON does not allow an int as key, therefore should automatically call ::toString to not violate the format. It should simply not be needed to create a separate data object expecially for json.

Java does not know generic types (like the String key in the JsonObject) in runtime. It is just checked at compile time. I can simply cast a Map<Any, Any> to Map<String, Int. It just may fail when processing something with it. I am casting my map to a string key map but in klaxon I still have to call toString.

@cbeust
Copy link
Owner

cbeust commented Nov 28, 2021

Understood, but even that commit contains extra changes that don't need to be there, such as calling joinToString() with a string instead of a char.

Realistically, this PR should only contain result.append(Render.renderString(k.toString())).append(':') and the test.

Would you mind opening a new PR (after rebasing, I just pushed a small change) with just these changes? Happy to merge then.

Thanks!

@Bixilon
Copy link
Contributor Author

Bixilon commented Nov 28, 2021

Whatever, see #345

@Bixilon Bixilon closed this Nov 28, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants