![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs for the JSON module. More...
This section describes the M2MB APIs for the JSON module.
JSON modules provides APIs to decodes a JSON string and fills the parameters in the provided structure. Similarly it also provides APIs to encode JSON string from the provided structure. The structure information and the JSON tag information are given to the JSON module in a proprietary embedded schema format. Each TAG in JSON string is defined in structured format that gives the detail information about it, like the tag name, tag type, info on where to decode and fill the data of the tag, tag data type.
typedef struct M2MB_JSON_COMPLEX_INFO M2MB_JSON_COMPLEX_INFO_T |
Json complex information structure.
Json complex information structure.
typedef struct M2MB_JSON_COMPLEX_OBJ M2MB_JSON_COMPLEX_OBJ_T |
Json complex object structure.
Json complex object structure.
typedef enum M2MB_JSON_DATA_TYPE M2MB_JSON_DATA_TYPE_T |
Data type supported by the json.
List of data types supported by json module.
typedef struct M2MB_JSON_DATE M2MB_JSON_DATE_T |
Json date structure json.
Date structure json module.
typedef struct M2MB_JSON_DATE_TIME M2MB_JSON_DATE_TIME_T |
Json date & time structure json.
Date & Time structure json module.
typedef struct M2MB_JSON_DURATION M2MB_JSON_DURATION_T |
Json duration structure.
Duration structure json module.
typedef struct M2MB_JSON_HEX M2MB_JSON_HEX_T |
HEX stream structure json.
Hex stream structure json module.
typedef struct M2MB_JSON_NODE M2MB_JSON_NODE_T |
Json node structure.
Json node structure.
typedef struct M2MB_JSON_OBJ M2MB_JSON_OBJ_T |
Json object structure.
Json object structure.
typedef enum M2MB_JSON_OBJ_TYPE M2MB_JSON_OBJ_TYPE_T |
Object type supported by the json.
List of object types supported by json module.
typedef struct M2MB_JSON_TIME M2MB_JSON_TIME_T |
Json time structure json.
Time structure json module.
enum M2MB_JSON_DATA_TYPE |
Data type supported by the json.
List of data types supported by json module.
Definition at line 80 of file m2mb_json.h.
enum M2MB_JSON_OBJ_TYPE |
Object type supported by the json.
List of object types supported by json module.
Enumerator | |
---|---|
M2MB_JSON_COMPLEX_ELEMENT | |
M2MB_JSON_SIMPLE_ELEMENT |
Definition at line 69 of file m2mb_json.h.
M2MB_STATUS_T m2mb_json_decode | ( | UINT8 * | parent_start, |
UINT8 * | parent_end, | ||
M2MB_JSON_COMPLEX_OBJ_T * | jsonSchema, | ||
UINT8 * | returnStruct | ||
) |
Decode API for JSON module.
This function decode the Json file,extract the data and fill that on user structure.
[in] | parent_start | The starting address of the Json file |
[in] | parent_end | The Ending address of the Json file. |
[in] | jsonSchema | |
[in] | returnStruct | The user structure buffer to be filled with the data. |
Example
M2MB_STATUS_T m2mb_json_encode | ( | M2MB_JSON_COMPLEX_OBJ_T * | jsonSchema, |
UINT8 * | usrStruct, | ||
UINT8 * | jsonFileBuffer, | ||
UINT32 | jsonFileBufferSize, | ||
UINT32 * | lenOfJsonWritten | ||
) |
Encode API for JSON module.
This function create the Json file from the data structure and the Json schema.
[in] | jsonSchema | |
[in] | usrStruct | The user structure which holds all data to be encoded. |
[in] | jsonFileBuffer | The user buffer which will be filled with the Json file. |
[in] | jsonFileBufferSize | Total Size of the user buffer. |
[in] | lenOfJsonWritten | Size of the user buffer filled with Json file. |
Example
UINT16 m2mb_json_node_get | ( | M2MB_JSON_NODE_T * | pCNode, |
UINT8 * | pPNStart, | ||
UINT8 * | pPNEnd | ||
) |
Get node API for JSON module.
This function gets the node details i.e. start and end pointer within the start and end pointer given.
[in] | pCNode | Json child node details. User has to fill the name of the tag and the API would fill the start and end pointer with in the pPNStart and pPNEnd pointer. |
[in] | pPNStart | The starting address of the Json file. |
[in] | pPNEnd | The Ending address of the Json file. |
Example
Occurrence of node present API for JSON module.
This function finds the occurrence of a tag within the start and end pointer given.
[in] | pTName | Name of the tag. |
[in] | pPNStart | The starting address of the Json file. |
[in] | pPNEnd | The Ending address of the Json file. |
Example