【发布时间】:2015-12-08 01:10:30
【问题描述】:
目前我只能实际读取包含 json 格式的 php 文件。
我想要做的是读取一个回显语句(json 格式)来代替读取实际文件。
到目前为止,这是我的 android 代码,用于请求包含 json 格式的 php 文件供我阅读:
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent(); // This is storing the contents from the php file
提前致谢
这是php文件:
{
"user": [
{
"id": "001",
"name": "Raj Amal",
"email": "raj.amalw@gmail.com"
}
]
}
I want to do this:
<?php
echo '{
"user": [
{
"id": "001",
"name": "Raj Amal",
"email": "raj.amalw@gmail.com"
}
]
}';
?>
【问题讨论】:
-
我不太清楚你在问什么 - 你得到的回应是什么,你为什么看不懂?需要解析 JSON 什么的吗?