var state = {
id: 1,
points: 100,
name: "Goran"
};
var newState = {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.serialization.* | |
import kotlinx.serialization.descriptors.SerialDescriptor | |
import kotlinx.serialization.encoding.CompositeDecoder | |
import kotlinx.serialization.encoding.Decoder | |
import kotlinx.serialization.encoding.Encoder | |
import kotlinx.serialization.json.* | |
import kotlin.reflect.KType | |
import kotlin.reflect.full.isSubtypeOf | |
import kotlin.reflect.full.starProjectedType |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP PROCEDURE IF EXISTS migrateById; | |
DELIMITER $$ | |
CREATE PROCEDURE migrateById() | |
BEGIN | |
DECLARE done INT DEFAULT FALSE; | |
DECLARE _post_id INT; | |
DECLARE migrate_ids CURSOR FOR | |
# modify the select statement to returns IDs, which will be assigned the variable `_post_id` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JsonDeserialize(using = KotlinDataDeserializer::class) | |
data class Foo(val x: String, val y: String, val z: Int) | |
class KotlinDataDeserializer : StdDeserializer<Foo>(Foo::class.java) { | |
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Foo { | |
return p.readValueAs(Foo::class.java) | |
} | |
override fun deserialize(p: JsonParser, ctxt: DeserializationContext, intoValue: Foo): Foo { | |
val copy = intoValue::copy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.annotation.JsonProperty | |
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | |
fun main(args: Array<String>) { | |
// val mapper = ObjectMapper().registerModule(KotlinModule()) | |
// val mapper = ObjectMapper().registerKotlinModule() | |
val mapper = jacksonObjectMapper() | |
val writer = mapper.writerWithDefaultPrettyPrinter() | |
val json1 = writer.writeValueAsString(Data1(1, "Foo", "Bar")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.databind.JsonNode | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import com.fasterxml.jackson.module.kotlin.KotlinModule | |
fun main(args: Array<String>) { | |
val jsonString : String = """ | |
{ | |
"authors" : [ | |
{ | |
"name" : "Kalle Jönsson", |