I am trying to stick to naming conventions in both JavaScript and C #. This leads to interesting questions when passing JSONized data back and forth. When I access the client side of the x / y coordinate, I expect the property to be lowercase, and on the server side in uppercase.
Note:
public class ComponentDiagramPolygon { public List<System.Drawing.Point> Vertices { get; set; } public ComponentDiagramPolygon() { Vertices = new List<System.Drawing.Point>(); } } public JsonResult VerticesToJsonPolygon(int componentID) { PlanViewComponent planViewComponent = PlanViewServices.GetComponentsForPlanView(componentID, SessionManager.Default.User.UserName, "image/png"); ComponentDiagram componentDiagram = new ComponentDiagram(); componentDiagram.LoadComponent(planViewComponent, Guid.NewGuid()); List<ComponentDiagramPolygon> polygons = new List<ComponentDiagramPolygon>(); if (componentDiagram.ComponentVertices.Any()) { ComponentDiagramPolygon polygon = new ComponentDiagramPolygon(); componentDiagram.ComponentVertices.ForEach(vertice => polygon.Vertices.Add(vertice)); polygons.Add(polygon); } return Json(polygons, JsonRequestBehavior.AllowGet); }
I understand that if I can use the C # attribute 'JsonProperty' to set up naming conventions. However, as far as I can tell, this only applies to the classes that I am.
How can I change the properties of System.Drawing.Point when passing back to the client?
source share