Question: suspend fun boroughsMapper ( jsonObj: JSONObject, localAssetsProvider: com.example.knownyc.data.local.provider.AssetsProvider, ) : List { val jsonArray:JSONArray = jsonObj.getJSONArray ( boroughs ) val boroughs:MutableList = mutableListOf

suspend fun boroughsMapper(
jsonObj: JSONObject,
localAssetsProvider: com.example.knownyc.data.local.provider.AssetsProvider,
): List {
val jsonArray:JSONArray = jsonObj.getJSONArray("boroughs")
val boroughs:MutableList = mutableListOf()
for (i: Int in 0 until jsonArray.length()){
val obj: JSONObject = jsonArray.getJSONObject(i)
val borough = Borough(
boroCode = obj.getString("borough").first(),
name = obj.getString("shortName"),
longName = obj.getString("fullName"),
image = localAssetsProvider.getDrawableResourceId(obj.getString("imageFilename")),
)
boroughs.add(borough)
}
return boroughs
}
i want to write the similar class to this called parksMapper. it looks similar to this but instead of data coming from localassestprovider it comes from NycParkResponse data class
@Serializable
data class NycParksResponse(
@SerialName(value = "signname")
val signName : String?,
val location : String?,
val url : String?,
)
this is my NycParkResponse data class how can i pass this to the object in a mapper can you please write a mapper class similar to boroughMapper class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!