The string obtained through packet capture is shown in jsonString. If you are familiar with deserialization, you can provide the following types:
String jsonString = @"{
"" Black "": [],
"" White "": [],
"" Contact "":[
{
"" Pinyin "":"""",
"" Nickname "": "" r "",
"" Id "": 575056787,
"" Email ":" "codemo@126.com ""
},
{
"" Pinyin "":"""",
"" Nickname "": "r6 "",
"" Id "": 575074340,
"" Email ":" "codemo@163.com ""
},
{
"" Pinyin "":"""",
"" Nickname "": "yi "",
"" Id "": 574975530,
"" Email ":" "codemo@qq.com ""
},
{
"" Pinyin "":"""",
"" Nickname "": "" Swallow "",
"" Id "": 585384353,
"" Email ":" "codemo22@163.com ""
}
],
"" Group ": [],
"" Recent "": []
}";
# Region Address Book Collection
String rg_count = "contact \": [[] (? <Count> .*?) [] ";
String [] k = EmailHelp. GetRegValue (jsonString, rg_count, "count ");
String [] nickname = EmailHelp. GetRegValue (k [0], "nickname \":(? <Nickname> .*?) [,] "," Nickname ");
String [] email = EmailHelp. GetRegValue (k [0], "email \":(? <Email> .*?) [}] "," Email ");
String path = string. Format (@ "C: \ mail \" + "codemo@sohu.com ");
If (! Directory. Exists (path ))
{
Directory. CreateDirectory (path );
}
StreamWriter sw = new StreamWriter (path + '\' + "sohuContacts.csv ");
// Column name
Sw. WriteLine ("nickname, email account ");
// Traverse datatable to export data
For (int I = 0; I <nickname. Length; I ++)
{
StringBuilder sbText = new StringBuilder ();
SbText. Append (nickname [I] + ',' + email [I]);
// Write a row of the datatable
Sw. WriteLine (sbText. ToString ());
}
Sw. Flush ();
Sw. Close ();
# Endregion
From code example [codemo]