From b7d53f734709eaa82460b0de5b19e41e69ecf43c Mon Sep 17 00:00:00 2001 From: Jonathan B Date: Sat, 9 Oct 2021 15:42:31 +0200 Subject: Switch to JSON::Serializable --- shard.yml | 2 +- src/twitcr/mappings/token.cr | 10 +++++----- src/twitcr/mappings/user.cr | 16 ++++++++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/shard.yml b/shard.yml index 1452b12..0f4e13f 100644 --- a/shard.yml +++ b/shard.yml @@ -4,6 +4,6 @@ version: 0.3.0 authors: - Jonathan B. -crystal: 0.33.0 +crystal: "*" license: MIT diff --git a/src/twitcr/mappings/token.cr b/src/twitcr/mappings/token.cr index a141a68..3b9fcd8 100644 --- a/src/twitcr/mappings/token.cr +++ b/src/twitcr/mappings/token.cr @@ -1,7 +1,7 @@ struct Twitcr::Token - JSON.mapping({ - access_token: String, - expires_in: Int64, - token_type: String - }) + include JSON::Serializable + + property access_token : String + property expires_in : Int64 + property token_type : String end diff --git a/src/twitcr/mappings/user.cr b/src/twitcr/mappings/user.cr index 6ddd08b..c072549 100644 --- a/src/twitcr/mappings/user.cr +++ b/src/twitcr/mappings/user.cr @@ -2,15 +2,19 @@ require "./converters" module Twitcr struct UserList - JSON.mapping({data: Array(User)}) + include JSON::Serializable + + property data : Array(User) end struct User - JSON.mapping({ - id: {type: UInt64, converter: ID::Converter}, - login: String, - display_name: String, - }) + include JSON::Serializable + + @[JSON::Field(converter: ID::Converter)] + property id : UInt64 + + property login : String + property display_name : String end end -- cgit v1.2.3