如何使用Json获取数据?

时间:2015-11-16 07:26:52

标签: android json

我从服务器获取以下格式的数据。我可以使用JSON解析从服务器获取此数据。

"\r\nArray\n(\n [0] => Array\n (\n [rewardID] => 1\n [rewardTypeName] => Cash Reward\n [rewardDescription] => Winners are rewarded money\n )\n\n [1] => Array\n (\n [rewardID] => 2\n [rewardTypeName] => In-Kind Reward\n [rewardDescription] => Winners are acknowledged for their performance\n )\n\n [2] => Array\n (\n [rewardID] => 3\n [rewardTypeName] => Products or Services\n [rewardDescription] => Winners are rewarded with a product or service\n )\n\n [3] => Array\n (\n [rewardID] =>

1 个答案:

答案 0 :(得分:0)

这可能会对您有所帮助:

 private JSONObject json;
json = new JSONObject(bunldeString);
            String name = json.getString("name");
            String lname = json.getString("lname");
            String age =json.getString("age");

            String data = "Name ::  " + name + "\Last name :: " + lname + "\nAge::"+age;
            responseTV.setText(data);

根据您的数据更改参数age,name,lname。 干杯!