|
Distributed Publish & Subscribe for IoT
|
Convert between JSON and CBOR. More...
Functions | |
| DPS_Status | DPS_CBOR2JSON (const uint8_t *cbor, size_t cborLen, char *json, size_t jsonSize, int pretty) |
| Generate a JSON string from a CBOR encoded byte array. More... | |
| DPS_Status | DPS_JSON2CBOR (const char *json, uint8_t *cbor, size_t cborSize, size_t *cborLen) |
| Generate a CBOR encoded byte array from a JSON string. More... | |
Convert between JSON and CBOR.
| DPS_Status DPS_CBOR2JSON | ( | const uint8_t * | cbor, |
| size_t | cborLen, | ||
| char * | json, | ||
| size_t | jsonSize, | ||
| int | pretty | ||
| ) |
Generate a JSON string from a CBOR encoded byte array.
| cbor | CBOR encoded source data for the conversion |
| cborLen | The length of the CBOR data |
| json | Destination buffer for generated JSON string |
| jsonSize | The length of the JSON string buffer |
| pretty | If TRUE format the JSON using indentation and newlines, if FALSE the output is compact with no newlines or whitespace is inserted. |
| DPS_Status DPS_JSON2CBOR | ( | const char * | json, |
| uint8_t * | cbor, | ||
| size_t | cborSize, | ||
| size_t * | cborLen | ||
| ) |
Generate a CBOR encoded byte array from a JSON string.
Note that if there are multiple JSON elements in the input string only the first one is parsed and anything after the fist element is ignored.
| json | NUL terminated JSON string to convert |
| cbor | Destination buffer for the conversion |
| cborSize | The size of the cbor buffer |
| cborLen | Returns the number of CBOR bytes written |