Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions