From cbd162fd3bd07c25b67683b08ec97313d06b5ba0 Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Sun, 24 Feb 2019 17:22:45 +0100 Subject: [PATCH] simplified json serialization (changed Method to m and Value to v, to safe space for more valuable text) --- README.md | 4 +--- TelegramBotBase/Form/CallbackData.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6ce6d69..b771aef 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,7 @@ Below we have 3 options. ``` - String APIKey = ""; - - BotBase bb = new BotBase(APIKey); + BotBase bb = new BotBase("{YOUR API KEY}"); bb.SystemCalls.Add("/start"); bb.SystemCalls.Add("/form1"); diff --git a/TelegramBotBase/Form/CallbackData.cs b/TelegramBotBase/Form/CallbackData.cs index f7a74e3..3b50e31 100644 --- a/TelegramBotBase/Form/CallbackData.cs +++ b/TelegramBotBase/Form/CallbackData.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; namespace TelegramBotBase.Form { @@ -11,8 +13,10 @@ namespace TelegramBotBase.Form /// public class CallbackData { + [JsonProperty("m")] public String Method { get; set; } + [JsonProperty("v")] public String Value { get; set; } @@ -32,6 +36,10 @@ namespace TelegramBotBase.Form return new CallbackData(method, value).Serialize(); } + /// + /// Serializes data to json string + /// + /// public String Serialize() { String s = ""; @@ -48,6 +56,11 @@ namespace TelegramBotBase.Form return s; } + /// + /// Deserializes data from json string + /// + /// + /// public static CallbackData Deserialize(String data) { CallbackData cd = null;