/// <summary> /// Updates a PoI /// </summary> /// <param name="p">PoIInfo to update</param> /// <returns>true on success</returns> public bool Update (PoIInfo p) { string request = new UpdatePoIRequest(_poiUrl); string json = MiniJSON.Json.Serialize(p.ToDictionary(true)); string result = httpRequest.PostRequest(json, request); //Console.WriteLine(result); return !string.IsNullOrEmpty(result) && result.Equals("POI data updated succesfully!"); }
public void TestPoIInfo () { var fwCore = new FwCore (); fwCore.Location = new Location (52.365299224853516, 9.6899404525756836); fwCore.Category = "restaurant"; // var source = new Source (); // source.Name = "OpenStreetMap"; // source.WebSite = @"http://www.openstreetmap.org"; // source.Licence = @"http://www.openstreetmap.org/copyright"; // fwCore.Source = source; fwCore.Name = "Mi Pueblito"; fwCore.Description = "no steps, to wheelchair toilets"; fwCore.LastUpdate = new LastUpdate ("x", 1234); PoIInfo pInfo = new PoIInfo ("asdb-asdf-asdf-asdf"); pInfo.FwCore = fwCore; string jsonLocationString = @"""location"":{""wgs84"":{""latitude"":52.365299224853516,""longitude"":9.6899404525756836}}"; string jsonLastUpdateString = @"""last_update"":{""timestamp"":1234,""responsible"":""x""}"; string jsonNameString = @"""name"":{"""":""Mi Pueblito""}"; string jsonDescrString = @"""description"":{"""":""no steps, to wheelchair toilets""}"; string jsonCatString = @"""category"":""restaurant"""; //string jsonSourceString = @"""source"":{""name"":""OpenStreetMap"",""website"":""http://www.openstreetmap.org"",""license"":""http://www.openstreetmap.org/copyright""}"; string jsonFwCore = string.Format ("{0},{1},{2},{3},{4}", jsonLocationString, jsonNameString, jsonCatString, jsonDescrString, jsonLastUpdateString); string jsonPoi = @"{""asdb-asdf-asdf-asdf"":{""fw_core"":{" + jsonFwCore + "}}}"; //string jsonPoiUpdate = @"{""asdb-asdf-asdf-asdf"":{""fw_core"":{" + jsonFwCore + @"},""fw_time"":{""type"":""open""}}}"; var poiObject = MiniJSON.Json.Deserialize (jsonPoi) as System.Collections.Generic.Dictionary<string, object>; foreach (var k in poiObject) { var poiDeserialized = new PoIInfo (k); Assert.AreEqual (poiDeserialized, pInfo); } var poiSerialized = pInfo.ToDictionary (true); var poiJsonSerialized = MiniJSON.Json.Serialize (poiSerialized); Assert.AreEqual (jsonPoi, poiJsonSerialized); }
/// <summary> /// Serializes the PoI. /// </summary> /// <returns>The POI in json string</returns> /// <param name="pInfo">the PoI</param> public static string SerializePOI (PoIInfo pInfo) { var poiDic = pInfo.ToDictionary (); string json = MiniJSON.Json.Serialize (poiDic); return json; }