Concord - C Discord API library
A Discord API wrapper library written in C
JSON Conversion

Helpers for converting Discord data types to/from JSON. More...

Collaboration diagram for JSON Conversion:

Macros

#define discord_data_to_json(_symbol, _client, _data, _p_buf, _p_bufsize)
 Transform a Discord data type into a JSON string. More...
 
#define discord_data_to_jsonb(_symbol, _client, _jb, _data, _p_buf, _p_bufsize)
 Transform a Discord data type into a jsonb handle. More...
 
#define discord_data_from_json(_symbol, _client, _json, _len, _data)
 Parse a JSON string and fill a Discord data type. More...
 
#define discord_data_from_jsmnf(_client, _p, _json, _length, _type, _data)
 Parse a jsmnf_pair and fill a Discord data type. More...
 

Functions

CCORDcode discord_data_wrap_to_json (const struct reflectc_wrap *member, char *p_buf[], size_t *p_bufsize)
 Transform a wrapped Discord data type into a JSON string. More...
 
CCORDcode discord_data_wrap_to_jsonb (struct jsonb *jb, const struct reflectc_wrap *member, char *p_buf[], size_t *p_bufsize)
 Transform a wrapped Discord data type into a jsonb handle. More...
 
CCORDcode discord_data_wrap_from_json (const char *json, size_t len, struct reflectc_wrap *root)
 Parse a JSON string and fill a wrapped Discord data type. More...
 
CCORDcode discord_data_wrap_from_jsmnf (const struct jsmnf_pair *p, const char *json, size_t length, const struct reflectc_wrap *member)
 Parse a jsmnf_pair and fill a wrapped Discord data type. More...
 

Detailed Description

Helpers for converting Discord data types to/from JSON.

Macro Definition Documentation

◆ discord_data_to_json

#define discord_data_to_json (   _symbol,
  _client,
  _data,
  _p_buf,
  _p_bufsize 
)
Value:
discord_data_wrap_from(_symbol, _client, _data), _p_buf, _p_bufsize)
CCORDcode discord_data_wrap_to_json(const struct reflectc_wrap *member, char *p_buf[], size_t *p_bufsize)
Transform a wrapped Discord data type into a JSON string.
#define discord_data_wrap_from(_symbol, _client, _data)
Wrap a Discord data type into a reflectc_wrap structure.
Definition: discord.h:480

Transform a Discord data type into a JSON string.

Parameters
_symbolthe Discord data type symbol (with struct or union)
_clientthe client created with discord_from_token()
_datathe Discord data type to be transformed
_p_bufpointer to the JSON buffer
_p_bufsizepointer to the JSON buffer size
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary
Examples
components.c.

◆ discord_data_to_jsonb

#define discord_data_to_jsonb (   _symbol,
  _client,
  _jb,
  _data,
  _p_buf,
  _p_bufsize 
)
Value:
_jb, discord_data_wrap_from(_symbol, _client, _data), _p_buf, \
_p_bufsize)
CCORDcode discord_data_wrap_to_jsonb(struct jsonb *jb, const struct reflectc_wrap *member, char *p_buf[], size_t *p_bufsize)
Transform a wrapped Discord data type into a jsonb handle.

Transform a Discord data type into a jsonb handle.

Parameters
_symbolthe Discord data type symbol (with struct or union)
_clientthe client created with discord_from_token()
_jbthe jsonb handle
_datathe Discord data type to be transformed
_p_bufpointer to the JSON buffer
_p_bufsizepointer to the JSON buffer size
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary

◆ discord_data_from_json

#define discord_data_from_json (   _symbol,
  _client,
  _json,
  _len,
  _data 
)
Value:
_json, _len, discord_data_wrap_from(_symbol, _client, _data))
CCORDcode discord_data_wrap_from_json(const char *json, size_t len, struct reflectc_wrap *root)
Parse a JSON string and fill a wrapped Discord data type.

Parse a JSON string and fill a Discord data type.

Parameters
_symbolthe Discord data type symbol (with struct or union)
_clientthe client created with discord_from_token()
_jsonthe JSON string
_lenlength of json
_datathe Discord data type to be filled
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary
Examples
components.c, and embed.c.

◆ discord_data_from_jsmnf

#define discord_data_from_jsmnf (   _client,
  _p,
  _json,
  _length,
  _type,
  _data 
)
Value:
_p, _json, _length, discord_data_wrap_from(_type, _client, _data))
CCORDcode discord_data_wrap_from_jsmnf(const struct jsmnf_pair *p, const char *json, size_t length, const struct reflectc_wrap *member)
Parse a jsmnf_pair and fill a wrapped Discord data type.

Parse a jsmnf_pair and fill a Discord data type.

Parameters
_clientthe client created with discord_from_token()
_pthe jsmnf_pair
_jsonthe JSON string
_lengthlength of json
_typethe Discord data type symbol (without struct/union)
_datathe Discord data type to be filled
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary

Function Documentation

◆ discord_data_wrap_to_json()

CCORDcode discord_data_wrap_to_json ( const struct reflectc_wrap *  member,
char *  p_buf[],
size_t *  p_bufsize 
)

Transform a wrapped Discord data type into a JSON string.

Parameters
memberthe wrapped Discord data type
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary

◆ discord_data_wrap_to_jsonb()

CCORDcode discord_data_wrap_to_jsonb ( struct jsonb jb,
const struct reflectc_wrap *  member,
char *  p_buf[],
size_t *  p_bufsize 
)

Transform a wrapped Discord data type into a jsonb handle.

Parameters
jbthe jsonb handle
memberthe wrapped Discord data type
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary

◆ discord_data_wrap_from_json()

CCORDcode discord_data_wrap_from_json ( const char *  json,
size_t  len,
struct reflectc_wrap *  root 
)

Parse a JSON string and fill a wrapped Discord data type.

Parameters
jsonthe JSON string
lenlength of json
rootthe root wrapped Discord data type
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary

◆ discord_data_wrap_from_jsmnf()

CCORDcode discord_data_wrap_from_jsmnf ( const struct jsmnf_pair *  p,
const char *  json,
size_t  length,
const struct reflectc_wrap *  member 
)

Parse a jsmnf_pair and fill a wrapped Discord data type.

Parameters
pthe jsmnf_pair
jsonthe JSON string
lengthlength of json
memberthe wrapped Discord data type
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary