【发布时间】:2013-05-07 21:20:47
【问题描述】:
我想通过 http 向 php 服务器发送一条 json 消息。如您所见,我使用了 gson 库。
Gson gson = new Gson();
String[] data = {"value1", "value2", "value3"};
String json = gson.toJson(data);
String message = "jdata"+json; //I did this because of the server implementation
String path= "http://localhost/joomla/index.php?option=com_up1";
我想连接发送 (POST) 字符串 message 到位于 path 上的服务器 服务器将从消息中检索值,value1,value2,value3。
$jd = json_decode(JRequest::getVar( 'jdata'), true);
if (sizeof($jd)>0) {
$name = $jd[0];
$surname = $jd[1];
......
......
服务器会返回类似的消息
if ($db->query()) {
printf("OK");
我想在我的应用程序中显示。
如何将消息发送到服务器? 以及如何将消息从服务器读取到我的应用程序?
【问题讨论】:
-
如何使用 gson 发送 json 消息?
标签: android json http gson send