mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
Fix dollar sign escaping for json key names.
This commit is contained in:
@@ -303,7 +303,7 @@ internal class AdapterGenerator(
|
||||
|
||||
result.addStatement("%N.beginObject()", writerParam)
|
||||
propertyList.forEach { property ->
|
||||
result.addStatement("%N.name(%S)", writerParam, property.jsonName)
|
||||
result.addStatement("%N.name(\"${property.jsonName}\")", writerParam)
|
||||
result.addStatement("%N.toJson(%N, %N.%L)",
|
||||
nameAllocator.get(property.delegateKey), writerParam, valueParam, property.name)
|
||||
}
|
||||
|
@@ -128,7 +128,7 @@ internal data class TargetProperty(
|
||||
private val Element?.jsonName: String?
|
||||
get() {
|
||||
if (this == null) return null
|
||||
return getAnnotation(Json::class.java)?.name
|
||||
return getAnnotation(Json::class.java)?.name?.replace("$", "\\$")
|
||||
}
|
||||
|
||||
override fun toString() = name
|
||||
|
Reference in New Issue
Block a user