I am using Dictionary to build up key/value and need to stringify it for HTTP Post. They problem is when I stringify the data using Cordova’s JsonHelper, it displays the “key:” and “value:” then the actual key and value. I want to remove these.
I am developing for Windows Phone 8.
This:
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("user_id", user_id);
data.Add("order_id", order_id);
data.Add("package_id", package_id);
data.Add("order_status", "0"); //0 is success
data.Add("platform", "windows");
String postData = WPCordovaClassLib.Cordova.JSON.JsonHelper.Serialize(data);
Outputs:
[{"Key":"user_id","Value":"33"},{"Key":"order_id","Value":"07dbda1d-f877-4be8-b2d9-dba1f4622054"},{"Key":"package_id","Value":"package4"},{"Key":"order_status","Value":"0"},{"Key":"platform","Value":"windows"}]
You can use built-in Json serializer (JavaScriptSerializer)
or Json.Net (Which supports Supports .NET 2, .NET 3.5, .NET 4, Silverlight, Windows Phone and Windows 8)
Output would be: