/***********************************************************
* Copyright (C), 2021, LuxShare co.,
*
* File name : LuxcJSON
*
* Description :
*     JSON API
*
* History:
*
* <Date>         <Author>        <version>     <Modification>
* 2021/04/21    Laurence Zhou       0.01         First draft
***********************************************************/

#ifndef LUX_JSON_API_H
#define LUX_JSON_API_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cJSON.h"
#include "lux_system_api.h"


#define MAXSIZE 128

#ifdef true
#undef true
#endif
#define true ((cJSON_bool)1)
#ifdef false
#undef false
#endif
#define false ((cJSON_bool)0)


extern cJSON* LuxcJSONParseJsonFile(char* pcFileName);
extern char* LuxcJSONPrint(const cJSON* psItem);
extern cJSON* LuxcJSONGetObjectItem(const cJSON* const psObject, const char* const pcKey);
extern EFuncRetCode LuxcJSONGetObjectIntValue(const cJSON* const psObject, const char* const pcKey,int* piValue );
extern EFuncRetCode LuxcJSONGetObjectDoubleValue(const cJSON* const psObject,const char* const pcKey, double* pdValue);
extern EFuncRetCode LuxcJSONGetObjectStringValue(const cJSON* const psObject, const char* const pcKey, char* pcValue );
extern EFuncRetCode LuxcJSONGetObjectBooleanValue(const cJSON* const psObject, const char* const pcKey, cJSON_bool* pbValue);
extern EFuncRetCode LuxcJSONGetObjectArraySize(const cJSON* const psObject, const char* const pcKey, int* piSize);
extern EFuncRetCode LuxcJSONGetObjectIntArray(const cJSON* const psObject, const char* const pcKey, int* piArray,int* piSize);
extern EFuncRetCode LuxcJSONGetObjectDoubleArray(const cJSON* const psObject, const char* const pcKey, double* pdArray, int* piSize );
extern EFuncRetCode LuxcJSONGetObjectStringArray(const cJSON* const psObject, const char* const pcKey, char (*pcArray)[MAXSIZE],int* piSize);
extern EFuncRetCode LuxcJSONGetObjectIntArray2(const cJSON* const psObject, const char* const pcKey, int (*piArray2)[MAXSIZE],int* piRow, int* piColumn);
extern EFuncRetCode LuxcJSONGetObjectDoubleArray2(const cJSON* const psObject, const char* const pcKey, double (*pdArray2)[MAXSIZE],int* piRow, int* piColumn);
extern EFuncRetCode LuxcJSONDelete(cJSON* psItem);
extern EFuncRetCode LuxcJSONFree(void* psObject);

EFuncRetCode LuxcJSONGetOjectStringSize(const cJSON* const psObject, const char* const pcKey, int *piSize);
extern EFuncRetCode LuxcJSONGetArrayRowColumnSize(const cJSON* const psObject, const char* const pcKey, int* piRow,int* piColumn);

#endif /* LUX_JSON_API_H */
