I call everything like this:

VKRequest reqWall = VKApi.wall().get(VKParameters.from(VKApiConst.OWNER_ID, группа, VKApiConst.EXTENDED, 1, VKApiConst.COUNT, 100, "text")); reqWall.setPreferredLang("ru"); reqWall.executeWithListener(new VKRequest.VKRequestListener() { @Override public void onComplete(VKResponse response) { super.onComplete(response); JSONObject jsonObject = response.json; String owner = null; String audio = null, video = null, poll = null; try { owner = (((JSONObject) ((JSONArray) ((JSONObject) jsonObject.get("response")).get("items")).get(0)).getString("owner_id")); } catch (JSONException e) { e.printStackTrace(); } posts = new VKPostArray(); try { posts.parse(response.json); } catch (JSONException e) { e.printStackTrace(); } try { JSONArray array = ((JSONArray) ((JSONObject) jsonObject.get("response")).get("groups")); } catch (JSONException e) { e.printStackTrace(); } try { JSONArray attachments = ((JSONArray) ((JSONObject) jsonObject.get("response")).get("attachments")); JSONObject xx = (JSONObject) attachments.get(0); audio = xx.getJSONObject("audio").getString("url"); video = xx.getJSONObject("video").getString("mp4_360"); poll = xx.getJSONObject("poll").getString("answer"); } catch (JSONException e) { e.printStackTrace(); } try { VKApiPost post = posts.get(0); } catch (Exception e) { } 

There are no many questions to parse, but I can not parse for example in attachments of VkApiPoll.answers and for example VkApiVideo mp4_360 (comes null) ... help parse the attachment in the wall.get method, atoms have never had anything to do with this json

  • JSONArray attachments added, only it didn’t give me courage ( - sviter-pro
  • In my opinion you did not attach the full code. you do not have exceptions at the parsing stage? for example, if in this line JSONObject xx = (JSONObject) attachments.get(0); there will be an exception, the variables audio, video, poll will remain null - Mikhail Vaysman
  • Precisely ... because I don `t know how, because it never worked with json ... help me fix it? - sviter-pro
  • I just don't understand how in this code attachments affects posts ?? How can I not make posts? - sviter-pro
  • one
    In general, why do you need some kind of JSON? you can also use the reqWall.getItems().get(0).getAttachments().get(0). etc. is not it so? when you write get... after a dot get... IDE doesn't tell you anything? - Alexey Shimansky

0