1/*
2 * Copyright (c) 2022 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
16#ifndef SEC_UTILS_JSON_H
17#define SEC_UTILS_JSON_H
18
19#include <stdbool.h>
20#include <stdint.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26typedef void *DslmJsonHandle;
27
28DslmJsonHandle DslmCreateJson(const char *data);
29void DslmDestroyJson(DslmJsonHandle handle);
30
31int32_t DslmGetJsonFieldInt(DslmJsonHandle handle, const char *field);
32uint32_t DslmGetJsonFieldIntArray(DslmJsonHandle handle, const char *field, int32_t *array, int32_t arrayLen);
33const char *DslmGetJsonFieldString(DslmJsonHandle handle, const char *field);
34DslmJsonHandle DslmGetJsonFieldJson(DslmJsonHandle handle, const char *field);
35
36DslmJsonHandle DslmGetJsonFieldJsonArray(DslmJsonHandle handle, uint32_t num);
37int32_t DslmGetJsonFieldJsonArraySize(DslmJsonHandle handle);
38
39void DslmAddFieldIntToJson(DslmJsonHandle handle, const char *field, int32_t value);
40void DslmAddFieldIntArrayToJson(DslmJsonHandle handle, const char *field, const int32_t *array, int32_t arrayLen);
41void DslmAddFieldBoolToJson(DslmJsonHandle handle, const char *field, bool value);
42void DslmAddFieldStringToJson(DslmJsonHandle handle, const char *field, const char *value);
43void DslmAddFieldJsonToJson(DslmJsonHandle handle, const char *field, DslmJsonHandle json);
44
45char *DslmConvertJsonToString(DslmJsonHandle handle);
46
47bool DslmCompareJsonData(DslmJsonHandle handleA, DslmJsonHandle handleB, bool caseSensitive);
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif // SEC_UTILS_JSON_H