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

Support sending and receiving generic JSON values #83

Closed
Legioth opened this issue Sep 2, 2021 · 3 comments · Fixed by #2398
Closed

Support sending and receiving generic JSON values #83

Legioth opened this issue Sep 2, 2021 · 3 comments · Fixed by #2398
Assignees
Labels
enhancement New feature or request hilla Issues related to Hilla

Comments

@Legioth
Copy link
Member

Legioth commented Sep 2, 2021

Is your feature request related to a problem? Please describe.
There are situations where the exact structure of the data to send to or from the client isn't known. For such situations, it would be convenient if there would be built-in support for directly passing through a JSON representation.

Describe the solution you'd like
Since Fusion is otherwise based on Jackson for JSON, it would thus be natural if com.fasterxml.jackson.databind.JsonNode would be supported as a Java type. The corresponding TS type could be any. The value should basically just be passed straight through, rather than the current situation where JsonNode ends up in the part of the code that tries to deal with Iterable implementations.

Describe alternatives you've considered
In some limited cases, it's possible to model the data as e.g. a Map<String, SomeType>. In other cases, it's currently necessary to separately convert the JSON to a String which is passed over the network and then deserialized on the other side. This requires some redundant boilerplate code in the application, some network overhead from double encoding special characters, and some CPU overhead from the additional processing.

@Legioth Legioth added enhancement New feature or request hilla Issues related to Hilla labels Sep 2, 2021
@haijian-vaadin
Copy link
Contributor

First, investigate if we can get rid of the Jackson dep by using the native support from Java (or javax.json module).

Maybe better to use a custom serializer for this feature?

@Legioth
Copy link
Member Author

Legioth commented Sep 7, 2021

javax.json is not widely adopted. Jackson is.

@cromoteca
Copy link
Contributor

That probably requires the creation of a generator plugin like for Flux/Subscription, and the controller also needs to be modified to let that JSON pass through unmodified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hilla Issues related to Hilla
Projects
Development

Successfully merging a pull request may close this issue.

3 participants