hilla icon indicating copy to clipboard operation
hilla copied to clipboard

Support sending and receiving generic JSON values

Open Legioth opened this issue 4 years ago • 3 comments

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 avatar Sep 02 '21 10:09 Legioth

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?

haijian-vaadin avatar Sep 07 '21 11:09 haijian-vaadin

javax.json is not widely adopted. Jackson is.

Legioth avatar Sep 07 '21 11:09 Legioth

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.

cromoteca avatar Apr 29 '24 09:04 cromoteca