1 package com.netease.nimlib.sdk.chatroom.model;
3 import androidx.annotation.NonNull;
4 import androidx.annotation.Nullable;
10 import org.json.JSONArray;
11 import org.json.JSONException;
12 import org.json.JSONObject;
14 import java.util.ArrayList;
15 import java.util.List;
19 private static final String TAG_QUEUE_CHANGE =
"queueChange";
20 private static final String TAG_TYPE =
"_e";
21 private static final String TAG_ELEMENTS =
"elements";
26 private List<Map<String, String>> contentMapList = null;
34 public void parse(JSONObject json) {
36 if (json.has(TAG_QUEUE_CHANGE)) {
37 String queueChange = JSONHelper.getString(json, TAG_QUEUE_CHANGE);
38 JSONObject jsonObject = JSONHelper.parse(queueChange);
39 if (jsonObject == null) {
42 if (jsonObject.has(TAG_TYPE)) {
46 if (jsonObject.has(TAG_ELEMENTS)) {
47 String content = JSONHelper.getString(jsonObject, TAG_ELEMENTS);
48 JSONArray contentJsonArray = JSONHelper.parseArray(content);
49 if (contentJsonArray == null) {
52 int length = contentJsonArray.length();
53 contentMapList =
new ArrayList<>(length);
55 for (
int i = 0; i < length; ++i) {
56 contentMapList.add(JSONHelper.parseMapFromJsonObject(contentJsonArray.getJSONObject(i)));
58 }
catch (JSONException e) {
59 NimLog.uiError(
"parse elements error", e);
67 return chatRoomQueueChangeType;
72 return contentMapList;
78 return "ChatRoomQueueBatchAddAttachment{" +
79 ", " + super.toString() +
80 "chatRoomQueueChangeType=" + chatRoomQueueChangeType +
81 ", contentMapList=" + contentMapList +
void parse(JSONObject json)
通过json为当前对象赋值
Created by winnie on 2017/6/27.
ChatRoomQueueChangeType getChatRoomQueueChangeType()
List< Map< String, String > > getContentMapList()