我使用以下代码拆分查询字符串:
string y = reader.ReadToEnd();
Console.WriteLine(y.Length);
Console.WriteLine(y);
//Split rows
string[] x = Regex.Split(y,"\"rows\"");
Console.WriteLine(x[0]);
// replace the signs from string x like "}" with a space ""
x[1] = x[1].Replace("}]}","");
x[1] = x[1].Replace("\"", "");
Console.WriteLine(x[1]);
// split all records from string x wich are seperated by a comma
string[] r = Regex.Split(x[1], "},{");
foreach (string s in r)
{
Console.WriteLine(s);
string[] f = Regex.Split(s,",");
foreach (string p in f)
{
string[] a = Regex.Split(p, ":");
foreach (string q in a)
{
Console.WriteLine(q);
}
}
}
这是我使用的查询:
HttpWebRequest request = WebRequest.Create(UrlBase + Uri.EscapeUriString("&query=SELECT * FROM Table1 LIMIT 10")) as HttpWebRequest;
我得到的结果:
id
1
firstname
john
lastname
johnson
city
cicago
...
我现在要做的是将这些拆分记录放入另一个数据库。 我完全不知道下一步该做什么,所以如果有人能给我一些提示或一个例子,我会非常感激。