You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB
C

#include "../../object.h"
#define OBJ_TYPE struct ap_object
static struct json_object_field capabilities_layout[] = {
{
.key = "acceptsChatMessages",
.offset = offsetof( OBJ_TYPE, capabilities.accepts_chat_messages ),
.required = false,
.always_write = true,
.type = &json_field_bool,
},
JSON_FIELD_END,
};
#undef OBJ_TYPE
static bool capabilities_reader( struct json_pull_parser* jpp, void* field_data, struct json_object_field* layout_field_data )
{
struct ap_object* o = field_data;
o->capabilities.show = true;
return json_read_object_layout( jpp, capabilities_layout, field_data );
}
static bool capabilities_writer( struct json_writer* jw, const char* field_name, void* field_data, struct json_object_field* layout_field_data )
{
struct ap_object* o = field_data;
if( !o->capabilities.show ) { return false; }
write:
json_write_field_name(jw,field_name);
json_write_pretty_object_layout( jw, capabilities_layout, field_data );
return true;
}
struct json_field_type capabilities_type = {
.reader = capabilities_reader,
.writer = capabilities_writer,
.layout = capabilities_layout,
};