You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently skygear lambda function takes either Object[] args or Map<String, Object> as input parameter, and returns JSONObject on LambdaResponseHandler, which make serialization asymmetric (toMap and fromJson).
Suggest to return Map<String,Object> on LambdaResponseHandler.
For kotlin we can expect a uniform serialization like the following:
data class TestData(
val foo: String,
val nested: Nested
) {
data class Nested(
val nestedInt: Int,
val nestedString: String
) {
fun toMap() = mapOf(
"nestedInt" to nestedInt,
"nestedString" to nestedString
)
companion object {
@Throws(NullPointerException::class, ClassCastException::class)
fun from(map: Map<*,*>): Nested {
return Nested(
nestedInt = map["nestedInt"] as Int,
nestedString = map["nestedString"] as String
)
}
}
}
fun toMap() = mapOf(
"foo" to foo,
"nested" to nested.toMap()
)
companion object {
@Throws(NullPointerException::class, ClassCastException::class)
fun from(map: Map<*, *>): TestData {
return TestData(
foo = map["foo"] as String,
nested = Nested.from(map["nested"] as Map<*,*>)
)
}
}
}
The text was updated successfully, but these errors were encountered:
carmenlau
changed the title
Uniform pattern for lambda input/output serialize
Map<String,Object> support for lamda function
Jan 30, 2018
Since map is not the only result type for lambda, it would be string or array. So need further planning is needed. Will put this issue to backlog first and start planning again if it gets more votes.
Currently skygear lambda function takes either
Object[] args
orMap<String, Object>
as input parameter, and returnsJSONObject
onLambdaResponseHandler
, which make serialization asymmetric (toMap
andfromJson
).Suggest to return
Map<String,Object>
onLambdaResponseHandler
.For
kotlin
we can expect a uniform serialization like the following:The text was updated successfully, but these errors were encountered: