This file contains 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
//JsonProperty to allow Jackson to use setters and getters | |
data class Person( | |
@JsonProperty("name") val name: String, | |
@JsonProperty("occupation") val occupation: String | |
) |
This file contains 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
// Simple kotlin class without data keyword | |
class Person{ | |
lateinit var name: String | |
var occupation: String? = null | |
} |
This file contains 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.module.kotlin.registerKotlinModule | |
// import com.fasterxml.jackson.databind.ObjectMapper | |
val mapper = ObjectMapper().registerKotlinModule() | |
println(mapper.readValue(dataJSONStr, Person::class.java)) |
This file contains 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
// Person class with occupation as nullable property using ? | |
data class Person( | |
@JsonProperty("name") val name: String, | |
@JsonProperty("occupation") val occupation: String? // nullable | |
) |
This file contains 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
val dataJSONStr = """ | |
{ | |
"name": "Pavneet", | |
"occupation": "Software Engineer" | |
} | |
""".trimIndent() | |
val mapper = ObjectMapper() | |
println(mapper.readValue(dataJSONStr, Person::class.java)) |
This file contains 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
{ | |
"userId": 1, | |
"id": 1, | |
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", | |
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" | |
} |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<person> | |
<fname>Pavneet</fname> <!--first name--> | |
<lname>Singh</lname> <!--last name--> | |
<contacts> | |
<personal> | |
<phone>12345678900</phone> | |
</personal> | |
</contacts> | |
</person> |
This file contains 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
<person version="1.0" encoding="utf-8"> | |
<fname>Pavneet</fname> | |
<lname>Singh</lname> | |
<contacts> | |
<personal> | |
<phone>12345678900</phone> | |
</personal> | |
</contacts> | |
</person> |
This file contains 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 'dart:async'; | |
import 'package:flutter/material.dart'; | |
final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MaterialApp( | |
theme: ThemeData.light().copyWith(scaffoldBackgroundColor: darkBlue), | |
debugShowCheckedModeBanner: false, |
This file contains 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 React, { Component } from "react"; | |
import "./style.css"; | |
export default class App extends Component { | |
state = { | |
cart: ["Corn", "Potato"], | |
}; | |
addNewItem = () => { | |
this.setState((prevState) => ({ |