Exemple #1
0
        internal HabiticaTodo DeserializeTodo(string json)
        {
            JToken data = ParseResponseData(json);

            HabiticaTodo habiticaTodo = data.ToObject <HabiticaTodo>(serializer);

            return(habiticaTodo);
        }
Exemple #2
0
        /// <summary>
        /// Generate the API-conforming JSON of the given Todo.
        /// </summary>
        /// <param name="todo"></param>
        /// <returns></returns>
        internal string SerializeTodo(HabiticaTodo todo)
        {
            //Remove properties that can't be changed through UpdateTask of the API
            JObject jTodo = JObject.FromObject(todo);

            jTodo["Id"].Parent.Remove();
            jTodo["Completed"].Parent.Remove();
            jTodo["Checklist"].Parent.Remove();
            jTodo["CreatedAt"].Parent.Remove();
            jTodo["UpdatedAt"].Parent.Remove();

            using (StringWriter stringWriter = new StringWriter())
            {
                serializer.Serialize(stringWriter, jTodo);
                return(stringWriter.ToString());
            }
        }