Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Last active July 8, 2023 13:23
Show Gist options
  • Save saswata-dutta/f08ec2733f65a75f541a3d60f06a8ad6 to your computer and use it in GitHub Desktop.
Save saswata-dutta/f08ec2733f65a75f541a3d60f06a8ad6 to your computer and use it in GitHub Desktop.
:dependsOn org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.encodeToString
val input = JsonObject(hashMapOf(
"GroupName" to JsonPrimitive("<dev/prod grp name for taskRem>"),
"Name" to JsonPrimitive("<the uniq rem id>"),
"data" to JsonObject(hashMapOf(
"notificationType" to JsonPrimitive("whatsapp"),
"accountId" to JsonPrimitive(1234),
"payload" to JsonObject(hashMapOf(
"messaging_product" to JsonPrimitive("whatsapp"),
"to" to JsonPrimitive("<ph num>"),
"type" to JsonPrimitive("template"),
"template" to JsonObject(hashMapOf(
"name" to JsonPrimitive("<the template name>"),
"language" to JsonObject(hashMapOf("code" to JsonPrimitive("en_US"))),
"components" to JsonArray(listOf(
JsonObject(hashMapOf(
"type" to JsonPrimitive("body"),
"parameters" to JsonArray(listOf(
JsonObject(hashMapOf("type" to JsonPrimitive("text"), "text" to JsonPrimitive("<the taskName>"))),
JsonObject(hashMapOf("type" to JsonPrimitive("text"), "text" to JsonPrimitive("<the dueDate>")))
))
))
))
))
))
))
))
println(Json.encodeToString(input))
println(JsonPrimitive(Json.encodeToString(input)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment