hope I can get some valued assistance with a little issue I'm trying to work.
I've got an API endpoint which is sending data with the following request schema:
{
"type": String,
"coordinates": [
0.949492,
48.77163
]
}
As can be seen; the coordinates from the search are provided as two INT values, without parameters.
I'm trying to create an automated test for this, and I've put the above in a data class so it can be used all over the suite as-needed.
My data class is currently looking like the below example, but I don't know how to properly define a list for coordinates without a val or var parameter. I've defined it as a var called "list" for now so it stops throwing compilation errors. How should I be representing this list of coordinates?
data class SearchRequest(
val type: String,
val coordinates: List<Coordinates>
)
data class Coordinates(
var list: Int
)
CodePudding user response:
The second parameter is a list of Float
values, there is no need to create a separate class for that, Float
can be used:
data class SearchRequest(
val type: String,
val coordinates: List<Float>
)
CodePudding user response:
In addition to the answers above, you can also download a plugin from android studio that does this for you by just pasting the API's JSON format. The plugin name is JSON to Kotlin class converter, I think.