You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
privateinlinefun <T:Any> JsonPrimitive.primitive(primitive:String, block:JsonPrimitive.() ->T?): T {
137
+
privateinlinefun <T:Any> JsonPrimitive.primitive(primitive:String, block:JsonPrimitive.() ->T?): T {
138
138
try {
139
139
return block() ?: unparsedPrimitive(primitive)
140
140
} catch (e:IllegalArgumentException) {
@@ -236,9 +236,16 @@ private open class JsonTreeDecoder(
236
236
}
237
237
// Slow path
238
238
val deserializationNamesMap = json.deserializationNamesMap(descriptor)
239
-
val nameInObject = value.keys.find { deserializationNamesMap[it] == index }
240
-
val fallbackName = strategy?.serialNameForJson(descriptor, index, descriptor.getElementName(index)) // Key not found exception should be thrown with transformed named, not original
241
-
return nameInObject ?: fallbackName ?: baseName
239
+
value.keys.find { deserializationNamesMap[it] == index }?.let {
240
+
return it
241
+
}
242
+
243
+
val fallbackName = strategy?.serialNameForJson(
244
+
descriptor,
245
+
index,
246
+
baseName
247
+
) // Key not found exception should be thrown with transformed name, not original
Copy file name to clipboardExpand all lines: formats/json/jsMain/src/kotlinx/serialization/json/internal/DynamicDecoders.kt
+9-3
Original file line number
Diff line number
Diff line change
@@ -112,9 +112,15 @@ private open class DynamicInput(
112
112
}
113
113
// Slow path
114
114
val deserializationNamesMap = json.deserializationNamesMap(descriptor)
115
-
val nameInObject = (keys asArray<String>).find { deserializationNamesMap[it] == index }
116
-
val fallbackName = strategy?.serialNameForJson(descriptor, index, descriptor.getElementName(index)) // Key not found exception should be thrown with transformed name, not original
117
-
return nameInObject ?: fallbackName ?: mainName
115
+
(keys asArray<String>).find { deserializationNamesMap[it] == index }?.let {
116
+
return it
117
+
}
118
+
val fallbackName = strategy?.serialNameForJson(
119
+
descriptor,
120
+
index,
121
+
mainName
122
+
) // Key not found exception should be thrown with transformed name, not original
123
+
return fallbackName ?: mainName
118
124
}
119
125
120
126
overridefundecodeTaggedEnum(tag:String, enumDescriptor:SerialDescriptor): Int {
0 commit comments