Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Conversation

@sciwhiz12
Copy link
Contributor

@sciwhiz12 sciwhiz12 commented Oct 27, 2025

This PR fixes #1 by implementing a custom deserializer for Component in the form of JsonTransformingSerializer, which transforms string-only components with their equivalent object-form component and otherwise delegates to the plugin-generated serializer. A test is added to check the behavior.

This also adjusts the "Run Tests" run configuration slightly to remove a reference to a named JRE, so the run configuration works with the module JRE.

The second part of that issue regarding a crash for the extras field in JSON deserialization seems to not be applicable, perhaps due to the rewrite made in the commit immediately after the one the linked issue mentions.


Side-notes:

  • I find it quite interesting that Component(text = "test") == Component(text = "test") evaluates to false. I'm not knowledgeable enough in Kotlin to understand why that happens though.
  • You should add a license to this repository, as a LICENSE file or otherwise at the root of the repository.

(P.S. Could I please ask you to add the hacktoberfest topic to your repository, or label this with a hacktoberfest-accepted label? Thank you!)

Use the module JRE rather than a specifically-named JRE.
This ensures that any way the Component class is deserialized will also
work, instead of only through JsonToComponentSerializer.
@LukynkaCZE LukynkaCZE merged commit 838ae7e into DockyardMC:master Oct 28, 2025
1 check passed
@LukynkaCZE
Copy link
Contributor

There you go, modtoberfest should accept it automatically without any extra labels

@sciwhiz12 sciwhiz12 deleted the deserialize-string-only-json branch October 28, 2025 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON serializer unable to decode JSON String into Components

2 participants