Serialize a function to JSON
Is there a way to serialize a function to JSON?
I try to do
Json.encodeToString(fun(i:Int): Int = i * 2)
I get “Class () is not registered for polymorphic serialization in the scope of ‘Function1’.
Mark the base class as ‘sealed’ or register the serializer explicitly”.
Marking the class as sealed does not work in my case as I don’t want to make this class abstract. In any case, this should have nothing to do with where the code is run from.
1 post - 1 participant
<a...