-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOD: jsonReader support Float, Array, Set and Map Type
- Loading branch information
1 parent
cb7bc97
commit 4d44653
Showing
9 changed files
with
179 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
20 changes: 20 additions & 0 deletions
20
kudos-compiler/testData/jsonReader/deserializeArrayType.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SOURCE | ||
{{deserialize}} | ||
// FILE: Main.kt [MainKt#main] | ||
import com.kanyun.kudos.annotations.Kudos | ||
|
||
@Kudos | ||
class User(val ids: Array<Int>) { | ||
|
||
override fun toString(): String { | ||
return "User(ids[1]=${ids[1]})" | ||
} | ||
} | ||
|
||
fun main() { | ||
deserialize<User>("""{"ids": [123, 456]}""") | ||
} | ||
|
||
// EXPECT | ||
// FILE: MainKt.main.stdout | ||
User(ids[1]=456) |
20 changes: 20 additions & 0 deletions
20
kudos-compiler/testData/jsonReader/deserializeFloatType.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SOURCE | ||
{{deserialize}} | ||
// FILE: Main.kt [MainKt#main] | ||
import com.kanyun.kudos.annotations.Kudos | ||
|
||
@Kudos | ||
class User(val doubleId: Double, val floatId: Float) { | ||
|
||
override fun toString(): String { | ||
return "User(doubleId=$doubleId, floatId=$floatId)" | ||
} | ||
} | ||
|
||
fun main() { | ||
deserialize<User>("""{"doubleId": 10.1234, "floatId": "10.1234"}""") | ||
} | ||
|
||
// EXPECT | ||
// FILE: MainKt.main.stdout | ||
User(doubleId=10.1234, floatId=10.1234) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SOURCE | ||
{{deserialize}} | ||
// FILE: Main.kt [MainKt#main] | ||
import com.kanyun.kudos.annotations.Kudos | ||
|
||
@Kudos | ||
class User(val id: Int, val tag: String){ | ||
override fun toString(): String { | ||
return "User(id=${id}, tag=${tag})" | ||
} | ||
} | ||
|
||
@Kudos | ||
class UserMap(val itemMap: Map<String, User>) { | ||
|
||
override fun toString(): String { | ||
return "UserMap(user2=${itemMap["user2"]})" | ||
} | ||
} | ||
|
||
fun main() { | ||
deserialize<UserMap>("""{ | ||
"itemMap": { | ||
"user1": { | ||
"id": 123, | ||
"tag": "tag1" | ||
}, | ||
"user2": { | ||
"id": 456, | ||
"tag": "tag2" | ||
} | ||
} | ||
}""") | ||
} | ||
|
||
// EXPECT | ||
// FILE: MainKt.main.stdout | ||
UserMap(user2=User(id=456, tag=tag2)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SOURCE | ||
{{deserialize}} | ||
// FILE: Main.kt [MainKt#main] | ||
import com.kanyun.kudos.annotations.Kudos | ||
|
||
@Kudos | ||
class User(val ids: Set<Int>) { | ||
|
||
override fun toString(): String { | ||
return "User(ids=${ids})" | ||
} | ||
} | ||
|
||
fun main() { | ||
deserialize<User>("""{"ids": [123, 456, 123]}""") | ||
} | ||
|
||
// EXPECT | ||
// FILE: MainKt.main.stdout | ||
User(ids=[123, 456]) |
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
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