* Deserializes provided value. * * @param {TypeLike } x Some value. * @param {SerializerContext >} serializerContext Serializer context. * * @returns {TypeLike >} Deserialized value or undefined.
(x: TypeLike<any>, serializerContext: SerializerContext<Record<string, any>>)
| 118 | * @returns {TypeLike<Record<string, any>>} Deserialized value or undefined. |
| 119 | */ |
| 120 | public deserialize(x: TypeLike<any>, serializerContext: SerializerContext<Record<string, any>>): TypeLike<Record<string, any>> |
| 121 | { |
| 122 | if (x === undefined) |
| 123 | { |
| 124 | return serializerContext.deserializedDefaultValue; |
| 125 | } |
| 126 | |
| 127 | if (x === null) |
| 128 | { |
| 129 | return serializerContext.deserializedNullValue; |
| 130 | } |
| 131 | |
| 132 | if (typeof x === 'object') |
| 133 | { |
| 134 | return serializerContext.restoreReference(x, () => |
| 135 | { |
| 136 | const object = x as Record<string, any>; |
| 137 | |
| 138 | const typeSerializerContext = serializerContext.polymorphic |
| 139 | ? serializerContext.definePolymorphicSerializerContext(x) |
| 140 | : serializerContext; |
| 141 | |
| 142 | const propertySerializerContext = typeSerializerContext.defineChildSerializerContext(); |
| 143 | const typeState = typeSerializerContext.typeState; |
| 144 | const typeEntryMap = new Map<PropertyName, TypeEntry<any, any>>(); |
| 145 | |
| 146 | propertySerializerContext.referenceValueSetter = (v, k) => |
| 147 | { |
| 148 | const declaringType = propertySerializerContext.referenceMap.get(object); |
| 149 | |
| 150 | if (declaringType !== undefined) |
| 151 | { |
| 152 | declaringType[k] = v; |
| 153 | } |
| 154 | }; |
| 155 | |
| 156 | for (let i = 0; i < typeState.sortedPropertyMetadatas.length; i++) |
| 157 | { |
| 158 | const propertyMetadata = typeState.sortedPropertyMetadatas[i]; |
| 159 | const propertyState = propertyMetadata.propertyState; |
| 160 | |
| 161 | if (!propertyState.deserializable) |
| 162 | { |
| 163 | continue; |
| 164 | } |
| 165 | |
| 166 | const serializedPropertyName = propertyState.serializedPropertyName; |
| 167 | const deserializedPropertyName = propertyState.deserializedPropertyName; |
| 168 | const propertyValue = object[serializedPropertyName]; |
| 169 | |
| 170 | propertySerializerContext.jsonPathKey = serializedPropertyName; |
| 171 | propertySerializerContext.propertyState = propertyState; |
| 172 | propertySerializerContext.typeState = propertyState.typeMetadata.typeState; |
| 173 | propertySerializerContext.genericMetadatas = propertyState.genericMetadatas; |
| 174 | |
| 175 | const serializer = propertySerializerContext.serializer; |
| 176 | const value = serializer.deserialize(propertyValue, propertySerializerContext); |
| 177 |
nothing calls this directly
no test coverage detected