0

我有一个 Json 格式的 Json Url

http://inter.youdao.com/intersearch?tag=simple-eh&from=en&to=hi&q=spin

我只需要首先我

第一个 i - n。घुमाव; चक्रण; झुकाव</p>

第二 iv घूमना; कातना</p>

是否有可能第一个 i + 第二个 i 单词只有第一个单词 = n。घुमाव, v. घूमना</p>

问题是在 android no eh velue 中显示结果。如何获得印地语单词。

json结果

{
"data": {
"eh": {
"": "spɪn",
"ukphone": "spɪn",
"ukspeech": "spin&type=1",
"trs": [
{
"i": "n. घुमाव; चक्रण; झुकाव"
},
{
"i": "v. घूमना; कातना"
}
],

安卓实现:

    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.GET,
                    urlJsonObj, null, new Response.Listener<JSONObject>() { @Override
                        public void onResponse(JSONObject response) {
                            Log.d(TAG, response.toString());
                             try {
                                // Parsing json object response
                                // response will be a json object
                            JSONObject result = response.getJSONObject("data");
                                String eh= result.getString("eh");
                                JSONObject result1 = response.getJSONObject("eh");
                                String hindi= result1.getString("trs");
                                jsonResponse = "";
                                jsonResponse += "Hindi: " + hindi ;
                                txtResponse.setText(jsonResponse);
} catch (JSONException e) {
                            e.printStackTrace();
                            Toast.makeText(getApplicationContext(),
                                    "Error: " + e.getMessage(),
                                    Toast.LENGTH_LONG).show();
                        }
                        hidepDialog();
                    }
                }, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError error) {
                        VolleyLog.d(TAG, "Error: " + error.getMessage());
                        Toast.makeText(getApplicationContext(),
                                error.getMessage(), Toast.LENGTH_SHORT).show();
                        // hide the progress dialog
                        hidepDialog();
                    }
                });

        // Adding request to request queue
        AppController.getInstance().addToRequestQueue(jsonObjReq);
    }
4

1 回答 1

0

最终解决问题

谢谢这里是代码:

try {
                        // Parsing json object response
                        // response will be a json object
                        String syncresponse = response.getString("data");
                        JSONObject object2 = new JSONObject(syncresponse);
                        String synckey = object2.getString("eh");
                        JSONObject object3 = new JSONObject(synckey);
                        JSONArray jArray1 = object3.getJSONArray("trs");

                        for(int i = 0; i < jArray1 .length(); i++)
                        {
                            JSONObject object4 = jArray1.getJSONObject(i);
                            String comp_id = object4.getString("i");
                            String replace = object4.getString( "i" ).replace( ";", "," );

                            translate.setText(mWord + "=" + comp_id);
                        }
于 2019-02-14T05:55:06.623 回答