Json C#将变量添加到json字符串中

时间:2016-08-15 01:53:25

标签: c# json

我想将字符串用户名和密码添加到字符串jsonData中,但似乎有错误。

@Override
public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

      WebView webView = (WebView) findViewById(R.id.mywebview);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.loadUrl("http://maps.googleapis.com/maps/api/staticmap?
       ll=36.97,%20-122&lci=bike&z=13&t=p&size=500x500&sensor=true");
}

1 个答案:

答案 0 :(得分:0)

使用RestSharp进行REST API调用,使用NewtoSoft将对象序列化为JSON。您的代码已过时。

http://restsharp.org/

http://www.newtonsoft.com/json

顺便说一句......你的错误是“密码”的顺序

你有

string jsonData = @"{""AdminNo"" : """+username+""", """+password+""" : ""password""}";

应该是

string jsonData = @"{""AdminNo"" : """+username+""", ""password"" : """+password+"""}";