lib/json: document how to refine `accept_json_serializer` and make it protected
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 12 May 2016 13:29:55 +0000 (09:29 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 13 May 2016 18:18:04 +0000 (14:18 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/json/serialization.nit

index c14c734..65d5cbf 100644 (file)
@@ -533,7 +533,15 @@ redef class Serializable
                return stream.to_s
        end
 
-       private fun accept_json_serializer(v: JsonSerializer)
+       # Refinable service to customize the serialization of this class to JSON
+       #
+       # This method can be refined to customize the serialization by either
+       # writing pure JSON directly on the stream `v.stream` or
+       # by using other services of `JsonSerializer`.
+       #
+       # Most of the time, it is preferable to refine the method `core_serialize_to`
+       # which is used by all the serialization engines, not just JSON.
+       protected fun accept_json_serializer(v: JsonSerializer)
        do
                var id = v.cache.new_id_for(self)
                v.stream.write "\{"