Deserialize the attribute with name from the object open for deserialization

The static_type restricts what kind of object can be deserialized.

Return the deserialized value or null on error, and set deserialize_attribute_missing to whether the attribute was missing.

Internal method to be implemented by the engines.

Property definitions

serialization $ Deserializer :: deserialize_attribute
	# Deserialize the attribute with `name` from the object open for deserialization
	#
	# The `static_type` restricts what kind of object can be deserialized.
	#
	# Return the deserialized value or null on error, and set
	# `deserialize_attribute_missing` to whether the attribute was missing.
	#
	# Internal method to be implemented by the engines.
	fun deserialize_attribute(name: String, static_type: nullable String): nullable Object is abstract
lib/serialization/serialization_core.nit:118,2--126,99

json $ JsonDeserializer :: deserialize_attribute
	redef fun deserialize_attribute(name, static_type)
	do
		if path.is_empty then
			# The was a parsing error or the root is not an object
			if not root isa Error then
				errors.add new Error("Deserialization Error: parsed JSON value is not an object.")
			end
			deserialize_attribute_missing = false
			return null
		end

		var current = path.last

		if not current.keys.has(name) then
			# Let the generated code / caller of `deserialize_attribute` raise the missing attribute error
			deserialize_attribute_missing = true
			return null
		end

		var value = current[name]

		attributes_path.add name
		var res = convert_object(value, static_type)
		attributes_path.pop

		deserialize_attribute_missing = false
		return res
	end
lib/json/serialization_read.nit:53,2--80,4

msgpack $ MsgPackDeserializer :: deserialize_attribute
	redef fun deserialize_attribute(name, static_type)
	do
		if path.is_empty then
			# The was a parsing error or the root is not an object
			deserialize_attribute_missing = false
			return null
		end

		var current = path.last

		var serialized_value = null
		var serialized_value_found = false
		if current.keys.has(name) then
			# Non-cached string
			serialized_value = current[name]
			serialized_value_found = true
		else
			# It may be cached, deserialize all keys until we find it
			for key in current.keys.to_a do
				if key isa Array[nullable Serializable] or key isa MsgPackExt then
					var str = convert_object(key, "String")
					if str isa String then
						var value = current[key]
						current.keys.remove key
						current[str] = value

						if str == name then
							serialized_value = value
							serialized_value_found = true
							break
						end
					end
				end
			end
		end

		if not serialized_value_found then
			# Let the generated code / caller of `deserialize_attribute` raise the missing attribute error
			deserialize_attribute_missing = true
			return null
		end

		attributes_path.add name
		var res = convert_object(serialized_value, static_type)
		attributes_path.pop

		deserialize_attribute_missing = false
		return res
	end
lib/msgpack/serialization_read.nit:105,2--153,4