hilla
hilla copied to clipboard
Support sending and receiving generic JSON values
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.
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?
javax.json is not widely adopted. Jackson is.
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.