18 lines
443 B
C++
18 lines
443 B
C++
#pragma once
|
|
#include "cJSON.h"
|
|
#include <string>
|
|
|
|
struct ProtocolMessage {
|
|
int v;
|
|
std::string id;
|
|
std::string type;
|
|
uint64_t ts;
|
|
std::string deviceId; // C++ строка
|
|
cJSON* payload;
|
|
};
|
|
|
|
// Создание JSON из структуры
|
|
cJSON* protocol_message_to_json(const ProtocolMessage *msg);
|
|
|
|
// Разбор JSON в структуру
|
|
int protocol_json_to_message(const char *json_str, ProtocolMessage *msg); |