I have a way:
public JsonResult Layar(string countryCode, string timestamp, string userId, string developerId, string layarName, double radius, double lat, double lon, double accuracy) { LayarModel model = new LayarModel(lat, lon, radius); return Json(model, JsonRequestBehavior.AllowGet); }
It returns this object:
public class LayarModel { private List<HotSpot> _hotSpots = new List<HotSpot>(); public List<HotSpot> HotSpots { get { return _hotSpots; } set { _hotSpots = value; } } public string Name { get; set; } public int ErrorCode { get; set; } public string ErrorString { get; set; } }
I want JSON to be
{"hotspots": [{ "distance": 100, "attribution": "The Location of the Layar Office", "title": "The Layar Office", "lon": 4884339, "imageURL": http:\/\/custom.layar.nl\/layarimage.jpeg, "line4": "1019DW Amsterdam", "line3": "distance:%distance%", "line2": "Rietlandpark 301", "actions": [], "lat": 52374544, "type": 0, "id": "test_1"}], "layer": "snowy4", "errorString": "ok", "morePages": false, "errorCode": 0, "nextPageKey": null }
Everything comes out in capital letters, as in the returned class ( HotSpots instead of HotSpots ).
I tried DataContract and DataMembers (Name = "Test"), but this does not work. Any suggestions?