Message object
*/
public class Message implements Validable {
@SerializedName("action")
private MessageAction action;
/**
Only for messages from community. Contains user ID of community admin, who sent this message.
*/
@SerializedName("admin_author_id")
private Integer adminAuthorId;
@SerializedName("attachments")
private List attachments;
/**
Unique auto-incremented number for all messages with this peer
*/
@SerializedName("conversation_message_id")
private Integer conversationMessageId;
/**
Date when the message has been sent in Unixtime
*/
@SerializedName("date")
@Required
private Integer date;
/**
Is it an deleted message
*/
@SerializedName("deleted")
private BoolInt deleted;
/**
Message author's ID
*/
@SerializedName("from_id")
private Integer fromId;
/**
Forwarded messages
*/
@SerializedName("fwd_messages")
private List fwdMessages;
@SerializedName("geo")
private Geo geo;
/**
Message ID
*/
@SerializedName("id")
@Required
private Integer id;
/**
Is it an important message
*/
@SerializedName("important")
private Boolean important;
приходит json вида: ` { "group_id" :,
"type" : "message_new",
"event_id" : "",
"v" : "5.131",
"object" : {
"message" : {
"date" : 1672387895,
"from_id" : ,
"id" : ,
"out" : 0,
"attachments" : [
],
"conversation_message_id" : ,
"fwd_messages" : [
],
"important" : false,
"is_hidden" : false,
"peer_id" : 8342610,
"random_id" : 0,
"text" : "ывц3к4ас уавау"
},
"client_info" : {
"button_actions" : [
"text",
"vkpay",
"open_app",
"location",
"open_link",
"open_photo",
"callback",
"intent_subscribe",
"intent_unsubscribe"
],
"keyboard" : true,
"inline_keyboard" : true,
"carousel" : true,
"lang_id" : 0
}
}
}
`
В sdk парсинг джейсона в класс происходит в 2 этапа: 1) сначала парсим в класс CallbackMessage
`public class CallbackMessage {
`
где object с типом JsonObject получает значение:
{ "message" : { "date" : 1672387895, "from_id" : <from_id>, "id" : <id>, "out" : 0, "attachments" : [ ], "conversation_message_id" : <conversation_message_id>, "fwd_messages" : [ ], "important" : false, "is_hidden" : false, "peer_id" : 8342610, "random_id" : 0, "text" : "ывц3к4ас уавау" }, "client_info" : { "button_actions" : [ "text", "vkpay", "open_app", "location", "open_link", "open_photo", "callback", "intent_subscribe", "intent_unsubscribe" ], "keyboard" : true, "inline_keyboard" : true, "carousel" : true, "lang_id" : 0 } }
и имеет структуру
2) этап 2 мы пытаемся попарсить
[ "message" : {...}, "client_info" : {...} ]
в класс
` /**
Message object */ public class Message implements Validable { @SerializedName("action") private MessageAction action;
/**
@SerializedName("attachments") private List attachments;
/**
/**
/**
/**
/**
@SerializedName("geo") private Geo geo;
/**
/**
@SerializedName("is_hidden") private Boolean isHidden;
/**
@SerializedName("keyboard") private Keyboard keyboard;
/**
/**
@SerializedName("payload") private String payload;
/**
/**
@SerializedName("ref") private String ref;
@SerializedName("ref_source") private String refSource;
@SerializedName("reply_message") private ForeignMessage replyMessage;
/**
/**
/**
/**
/**
...
}
`
и получаем null
тк есть лишний объект "client_info" : {...}