Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public data class Locator(
val otherLocations: @WriteWith<JSONParceler> Map<String, Any> = emptyMap(),
) : JSONable, Parcelable {

override fun toJSON(): JSONObject = JSONObject(otherLocations).apply {
// Some versions of org.json's JSONObject(Map) store the reference directly
// without copying, so the map must be mutable.
override fun toJSON(): JSONObject = JSONObject(otherLocations.toMutableMap()).apply {
putIfNotEmpty("fragments", fragments)
put("progression", progression)
put("position", position)
Expand Down Expand Up @@ -285,7 +287,7 @@ public data class LocatorCollection(
*/
val title: String? get() = localizedTitle?.string

override fun toJSON(): JSONObject = JSONObject(otherMetadata).apply {
override fun toJSON(): JSONObject = JSONObject(otherMetadata.toMutableMap()).apply {
putIfNotEmpty("title", localizedTitle)
putOpt("numberOfItems", numberOfItems)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public data class Metadata(
/**
* Serializes a [Metadata] to its RWPM JSON representation.
*/
override fun toJSON(): JSONObject = JSONObject(otherMetadata).apply {
override fun toJSON(): JSONObject = JSONObject(otherMetadata.toMutableMap()).apply {
put("identifier", identifier)
put("@type", type)
putIfNotEmpty("conformsTo", conformsTo.map { it.uri })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public data class Properties(
/**
* Serializes a [Properties] to its RWPM JSON representation.
*/
override fun toJSON(): JSONObject = JSONObject(otherProperties)
override fun toJSON(): JSONObject = JSONObject(otherProperties.toMutableMap())

/**
* Makes a copy of this [Properties] after merging in the given additional other [properties].
Expand Down
Loading