fix name of var
This commit is contained in:
parent
47a9784100
commit
547de2d48c
|
@ -95,7 +95,7 @@ typedef struct reflect_item_t {
|
|||
size_t size; /**< size of property */
|
||||
cson_type type; /**< corresponding json type */
|
||||
const struct reflect_item_t* reflect_tbl; /**< must be specified when type is object or array */
|
||||
size_t arraySize; /**< size of per array item. must be specified when type is array */
|
||||
size_t arrayItemSize; /**< size of per array item. must be specified when type is array */
|
||||
char* arrayCountField; /**< field saving array size */
|
||||
int nullable; /**< paser return failure when the field is not found and nullable equals to 0 */
|
||||
} reflect_item_t;
|
||||
|
|
12
src/cson.c
12
src/cson.c
|
@ -263,10 +263,10 @@ int getJsonArray(void* input, const reflect_item_t* tbl, int index, cson_t* obj)
|
|||
cson_t jotmp;
|
||||
|
||||
if (tbl[index].reflect_tbl[0].field[0] == '0') { /* field start with '0' mean basic types. */
|
||||
ret = jsonPackTbl[tbl[index].reflect_tbl[0].type](pSrc + (i * tbl[index].arraySize), tbl[index].reflect_tbl, 0, &jotmp);
|
||||
ret = jsonPackTbl[tbl[index].reflect_tbl[0].type](pSrc + (i * tbl[index].arrayItemSize), tbl[index].reflect_tbl, 0, &jotmp);
|
||||
} else {
|
||||
jotmp = cson_object();
|
||||
ret = csonStruct2JsonObj(jotmp, pSrc + (i * tbl[index].arraySize), tbl[index].reflect_tbl);
|
||||
ret = csonStruct2JsonObj(jotmp, pSrc + (i * tbl[index].arrayItemSize), tbl[index].reflect_tbl);
|
||||
}
|
||||
|
||||
if (ret == ERR_NONE) {
|
||||
|
@ -432,7 +432,7 @@ int parseJsonArray(cson_t jo_tmp, void* output, const reflect_item_t* tbl, int i
|
|||
return ERR_MISSING_FIELD;
|
||||
}
|
||||
|
||||
char* pMem = (char*)malloc(arraySize * tbl[index].arraySize);
|
||||
char* pMem = (char*)malloc(arraySize * tbl[index].arrayItemSize);
|
||||
if (pMem == NULL) return ERR_MEMORY;
|
||||
|
||||
long long successCount = 0;
|
||||
|
@ -442,9 +442,9 @@ int parseJsonArray(cson_t jo_tmp, void* output, const reflect_item_t* tbl, int i
|
|||
int ret;
|
||||
|
||||
if (tbl[index].reflect_tbl[0].field[0] == '0') { /* field start with '0' mean basic types. */
|
||||
ret = jsonObjProcTbl[tbl[index].reflect_tbl[0].type](item, pMem + (successCount * tbl[index].arraySize), tbl[index].reflect_tbl, 0);
|
||||
ret = jsonObjProcTbl[tbl[index].reflect_tbl[0].type](item, pMem + (successCount * tbl[index].arrayItemSize), tbl[index].reflect_tbl, 0);
|
||||
} else {
|
||||
ret = csonJsonObj2Struct(item, pMem + (successCount * tbl[index].arraySize), tbl[index].reflect_tbl);
|
||||
ret = csonJsonObj2Struct(item, pMem + (successCount * tbl[index].arrayItemSize), tbl[index].reflect_tbl);
|
||||
}
|
||||
|
||||
if (ret == ERR_NONE) {
|
||||
|
@ -717,7 +717,7 @@ void csonLoopProperty(void* pData, const reflect_item_t* tbl, loop_func_t func)
|
|||
long long size = getIntegerValueFromPointer(ptr, tbl[countIndex].size);
|
||||
|
||||
for (long long j = 0; j < size; j++) {
|
||||
csonLoopProperty(*((char**)pProperty) + j * tbl[i].arraySize, tbl[i].reflect_tbl, func);
|
||||
csonLoopProperty(*((char**)pProperty) + j * tbl[i].arrayItemSize, tbl[i].reflect_tbl, func);
|
||||
}
|
||||
} else if (tbl[i].type == CSON_OBJECT) {
|
||||
csonLoopProperty(pProperty, tbl[i].reflect_tbl, func);
|
||||
|
|
Loading…
Reference in New Issue