gamnit: make `SpriteSet` public so clients can use its services
[nit.git] / lib / json / serialization_read.nit
index 91959c1..a9ebcfd 100644 (file)
@@ -321,10 +321,10 @@ class JsonDeserializer
        # Current array open for deserialization, used by `SimpleCollection::from_deserializer`
        private var opened_array: nullable Array[nullable Object] = null
 
-       redef fun deserialize
+       redef fun deserialize(static_type)
        do
                errors.clear
-               return convert_object(root)
+               return convert_object(root, static_type)
        end
 
        # User customizable heuristic to infer the name of the Nit class to deserialize `json_object`
@@ -488,6 +488,26 @@ redef class Map[K, V]
                        var keys = v.path.last.get_or_null("__keys")
                        var values = v.path.last.get_or_null("__values")
 
+                       if keys == null and values == null then
+                               # Fallback to a plain object
+                               for key, value_src in v.path.last do
+                                       var value = v.convert_object(value_src)
+
+                                       if not key isa K then
+                                               v.errors.add new AttributeTypeError(self, "keys", key, "K")
+                                               continue
+                                       end
+
+                                       if not value isa V then
+                                               v.errors.add new AttributeTypeError(self, "values", value, "V")
+                                               continue
+                                       end
+
+                                       self[key] = value
+                               end
+                               return
+                       end
+
                        # Length is optional
                        if length == null and keys isa SequenceRead[nullable Object] then length = keys.length
 
@@ -532,7 +552,7 @@ end
 # Metamodel
 
 # Class inheritance graph as a `POSet[String]` serialized to JSON
-private fun class_inheritance_metamodel_json: NativeString is intern
+private fun class_inheritance_metamodel_json: CString is intern
 
 redef class Sys
        # Class inheritance graph