I caught up with the project that was developed by the company for us, unfortunately, we do not get much support, and in the long term we must secure support for this. The application consists of a simple web client (HTTP, JavaScript, Knockout Framework) and a REST API service (.NET 4.5, ASP.NET MVC, I think).
Currently, I am only modifying the client, so the server should work as expected.
On clients, I slightly changed the knockout representation model (added some computable ones and optimized the representation of some values). The View model consists of “Questions” and “Comments” (as an array of questions, this is actually a Bug tracker). If I create a new problem, the description is added to the first comment, the entire JSON.stringified model and posting to the .NET API Service. I supported Firebug that the JSON that is being sent looks like this:
{ "Id":0, "Title":"THis is a title", "Comments":[ { "Id":1, "Text":"this is the first comment" } ] }
On the client side, I have an "IssueController":
[HttpPost] public HttpResponseMessage PostIssues( Issue issue ) {
The problem domain model object also has an array for storing comments, but for this purpose it is already empty. There is no part in the .NET code that explicitly parses JSON, as I understand it, the MVC Framework does this implicitly using equal property names (is this correct?).
The deserialization was already working as expected, so the .NET code should be fine, but it looks like I modified JSON so that this implicit display of comments no longer works. Unfortunately, I do not have much experience with the .NET MVC Framework (or is it just the .NET WebAPI Framework, I can’t even tell you about it).
These are my questions:
- What is the .NET REST API Framework? How can I tell?
- How does this implicit JSON deserialization work and what are its pitfalls, for example, when parts of JSON do not receive deserialization, as expected? Especially on the client side (as I said, I did not change the server code)
- Any ideas on what I could do with JSON that he doesn't like the server anymore ?;)
EDIT
Issue.cs looks like this (simplified):
using System; using System.Collections.Generic; using System.Linq; using System.Web; using Bo; using Projects.DomainObjects; namespace Projects.Models { public class Issue : DomainObject { public Issue() { this.Comments = new List<Comment>(); } public long Id { get; set; } private string _Title; public string Title { get { return _Title; } set { _Title = value; NotifyChanged(); } } public List<Comment> Comments { get; set; } }
Comment.cs:
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Common; using Projects.DomainObjects; namespace Projects.Models { public class Comment : DomainObject { public Comment() { } public long Id { get; set; } public string Text { get; set; } }