• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef SOFTBUS_JSON_UTILS_H
16 #define SOFTBUS_JSON_UTILS_H
17 
18 #include <stdint.h>
19 
20 #include "cJSON.h"
21 #include "string.h"
22 #include "stdbool.h"
23 #include "softbus_log.h"
24 
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif
29 #endif
30 
31 bool GetJsonObjectStringItem(const cJSON *json, const char * const string, char *target, uint32_t targetLen);
32 
33 bool GetJsonObjectNumberItem(const cJSON *json, const char * const string, int *target);
34 
35 bool GetJsonObjectSignedNumberItem(const cJSON *json, const char * const string, int *target);
36 
37 bool GetJsonObjectNumber64Item(const cJSON *json, const char * const string, int64_t *target);
38 
39 bool GetJsonObjectDoubleItem(const cJSON *json, const char * const string, double *target);
40 
41 bool GetJsonObjectBoolItem(const cJSON *json, const char * const string, bool *target);
42 
43 bool AddStringToJsonObject(cJSON *json, const char * const string, const char *value);
44 
45 bool AddNumberToJsonObject(cJSON *json, const char * const string, int num);
46 
47 bool AddNumber64ToJsonObject(cJSON *json, const char * const string, int64_t num);
48 
49 bool AddBoolToJsonObject(cJSON *json, const char * const string, bool value);
50 
51 bool GetJsonObjectInt32Item(const cJSON *json, const char * const string, int32_t *target);
52 #ifdef __cplusplus
53 #if __cplusplus
54 }
55 #endif /* __cplusplus */
56 #endif /* __cplusplus */
57 #endif /* SOFTBUS_JSON_UTILS_H */