通过java接口,或者查询数据库返回json串。

可以有两种方式进行解读。

1.简单方式

没有深层结构,最好只有一条数据(当然也可多条)。可以用datatable来获取。返回的是clo0、clo1、clo2...这种标识。

这就要求事先知道列的内容,尤其是自己写的查询语句的时候。

DataTable dt0 = FromRuntime.sqlToDataTables(sql);
//如果有数据
if (dt0.Rows.Count > 0)
{
  //遍历dt0
  for (int i = 0; i < dt0.Rows.Count; i++)
  {
    //填充到列表
    DataList.Add(new DataModel(int.Parse(dt0.Rows[i]["col0"].ToString()), dt0.Rows[i]["col1"].ToString(), dt0.Rows[i]["col2"].ToString()));
  }
}

2.复杂方式

获取字符串后转换成键值对,然后遍历,当然,键值对的key也是事先知道的

string parameter = String.Format("loginUid={0}&id={1}", UserAndSecurity.g_userInfo.id, userAdd.m_userModel.Id);

string stsr = Inth.Https.FromRuntime.GetPageSourceToDataTable2("inth_user_show", parameter);

Dictionary<string, object> dic = Inth.Https.FromRuntime.JsonToDictionary(stsr);

if (dic["code"].ToString() != "SUCCESS")
{
MessageBox.Show(dic["msg"].ToString());
return;
}

Dictionary<string, object> dicData = (Dictionary<string, object>)dic["data"];

int.TryParse(dicData["id"].ToString(), out UserAndSecurity.g_userInfo.id);
UserAndSecurity.g_userInfo.name = dicData["name"].ToString();
UserAndSecurity.g_userInfo.password = dicData["password"].ToString();

//数组列表

ArrayList dicData = (ArrayList)item.Value;

foreach (Dictionary<string, object> itemMenus in dicData)
{

}

调用接口进行操作:

string parameter = String.Format("loginUid={0}&planId={1}&name={2}", UserAndSecurity.g_userInfo.id, m_iPlanId, textBox1.Text);

string stsr = Inth.Https.FromRuntime.GetPageSourceToDataTable2("inth_deliver_fee_add", parameter);

if (stsr.Contains("SUCCESS"))
{
MessageBox.Show("操作完成");
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("操作失败");
this.DialogResult = DialogResult.Cancel;
}

最新文章

  1. 深入理解springAOP
  2. android 设置布局横屏竖屏
  3. 大圆满的精髓–肯•威尔伯(KEN WILBER)
  4. poj.1988.Cube Stacking(并查集)
  5. ADT bundle和Eclipse和Android Studio有什么区别?安卓开发该用哪个?
  6. IOS NSThread
  7. 创建型模式之Singleton模式
  8. 优先队列(Priority Queue)
  9. 002..NET MVC实现自己的TempBag
  10. POJ 2421 Constructing Roads (最小生成树)
  11. [VS2012]无法新建或者编译已有的项目
  12. C++函数转换成C#函数
  13. ubuntu14.04下安装Naigos和pnp4nagios
  14. application&#160;windows&#160;are&#160;expected&#160;to&#160;have&#160;a&#160;root&#160;view&#160;controller错误
  15. Python之getopt模块
  16. [Qualcomm]A Detailed History of Qualcomm 高通的前世今生
  17. Shiro的认识
  18. rmq区间最值
  19. Django 数据库迁移
  20. Maven整合Spring3.0+Mybatis3.2+Struts2.3+查找坐标+jar包依赖(五)

热门文章

  1. (二)、Struts第二天
  2. hdu_2546_饭卡(01背包)
  3. 支付宝集成+网站支付+APP支付+手机网站支付
  4. jq模拟操作
  5. cookies和session的优缺点
  6. UIButton 解析
  7. PAT (Advanced Level) 1041. Be Unique (20)
  8. 分享我们项目中基于EF事务机制的架构 【转载】
  9. DEDECMS整站复制
  10. struts2-----新建项目