In the original article, the author explains how to use C # To Call JavaScript to parse JSON strings. CodeAs follows:
Copy codeThe Code is as follows: using Microsoft. JScript;
Using Microsoft. VSA;
Using Microsoft. JScript. VSA;
Public static dictionary <string, string> getmyvalue (string jsonsource, string key1, string key2)
{
Dictionary <string, string> DIC = new dictionary <string, string> ();
String jsonstr = "function handlejson () {var J =" + jsonsource + "; var arr1 = new array (); var arr2 = new array (); for (Var "+ key2 +" in J. "+ key1 +") arr1.push ("+ key2 +"); Return arr1;} handlejson ();";
Object o = eval. jscriptevaluate (jsonstr, vsaengine. createengine ());
Arrayobject arr = (arrayobject) O;
For (VAR I = 0; I <= (INT) Arr. Length-1; I ++)
{
Dic. Add (ARR [I]. tostring (), arr [I]. tostring ());
}
Return DIC;
}
This is basically the case. Call JS through C #, parse JSON with JS, and convert the returned value to a C # array.