In PhoneGap Documentation
"Developing a Plugin on Windows Phone" explain how parse simple array of string:
cordova.exec(win, fail, "ServiceName", "MethodName", ["this is a string", "54", "{literal:'trouble'}"]) ;
string[] optValues = JsonHelper.Deserialize(options);
But if you have something more complexity like this:
var moreBtns =
[
{
name : 'fb button',
target: 'EXTERNAL',
url : 'http://www.facebook.com'
},
{
name : 'twitter button',
target: 'EXTERNAL',
url : 'http://www.twitter.com'
}
];
cordova.exec(win, fail, "ServiceName", "MethodName", ["this is a string", "54", moreBtns]) ;
How to parse it?
First of all create class for more button
public class moreButtonClass
{
public string name { get; set; }
public string target { get; set; }
public string url { get; set; }
}
and then parse
string[] optValues = JsonHelper.Deserialize(options);
if (optValues.Length > 2)
{
moreButtonClass[] moreBtns = JsonHelper.Deserialize(optValues[3]);
for (int i = 0; i < moreBtns.Length; i++)
{
Debug.WriteLine("moreBtns[" + i + "][name]=" + moreBtns[i].name);
Debug.WriteLine("moreBtns[" + i + "][target]=" + moreBtns[i].target);
Debug.WriteLine("moreBtns[" + i + "][url]=" + moreBtns[i].url);
}
}