Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party CJSON
提交
73823c4b
T
Third Party CJSON
项目概览
OpenHarmony
/
Third Party CJSON
大约 1 年 前同步成功
通知
6
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party CJSON
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
73823c4b
编写于
4月 30, 2017
作者:
M
Max Bruckner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add get_object_item: configurable case_sensitivity
上级
0aaef1a8
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
18 addition
and
8 deletion
+18
-8
cJSON_Utils.c
cJSON_Utils.c
+18
-8
未找到文件。
cJSON_Utils.c
浏览文件 @
73823c4b
...
...
@@ -546,11 +546,21 @@ static cJSON_bool insert_item_in_array(cJSON *array, size_t which, cJSON *newite
return
1
;
}
static
cJSON
*
get_object_item
(
const
cJSON
*
const
object
,
const
char
*
name
,
const
cJSON_bool
case_sensitive
)
{
if
(
case_sensitive
)
{
return
cJSON_GetObjectItemCaseSensitive
(
object
,
name
);
}
return
cJSON_GetObjectItem
(
object
,
name
);
}
enum
patch_operation
{
INVALID
,
ADD
,
REMOVE
,
REPLACE
,
MOVE
,
COPY
,
TEST
};
static
enum
patch_operation
decode_patch_operation
(
const
cJSON
*
const
patch
)
static
enum
patch_operation
decode_patch_operation
(
const
cJSON
*
const
patch
,
const
cJSON_bool
case_sensitive
)
{
cJSON
*
operation
=
cJSON_GetObjectItem
(
patch
,
"op"
);
cJSON
*
operation
=
get_object_item
(
patch
,
"op"
,
case_sensitive
);
if
(
!
cJSON_IsString
(
operation
))
{
return
INVALID
;
...
...
@@ -623,7 +633,7 @@ static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_
unsigned
char
*
child_pointer
=
NULL
;
int
status
=
0
;
path
=
cJSON_GetObjectItem
(
patch
,
"path"
);
path
=
get_object_item
(
patch
,
"path"
,
case_sensitive
);
if
(
!
cJSON_IsString
(
path
))
{
/* malformed patch. */
...
...
@@ -631,7 +641,7 @@ static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_
goto
cleanup
;
}
opcode
=
decode_patch_operation
(
patch
);
opcode
=
decode_patch_operation
(
patch
,
case_sensitive
);
if
(
opcode
==
INVALID
)
{
status
=
3
;
...
...
@@ -640,7 +650,7 @@ static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_
else
if
(
opcode
==
TEST
)
{
/* compare value: {...} with the given path */
status
=
!
compare_json
(
get_item_from_pointer
(
object
,
path
->
valuestring
,
case_sensitive
),
cJSON_GetObjectItem
(
patch
,
"value"
),
case_sensitive
);
status
=
!
compare_json
(
get_item_from_pointer
(
object
,
path
->
valuestring
,
case_sensitive
),
get_object_item
(
patch
,
"value"
,
case_sensitive
),
case_sensitive
);
goto
cleanup
;
}
...
...
@@ -659,7 +669,7 @@ static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_
if
((
opcode
==
REPLACE
)
||
(
opcode
==
ADD
))
{
value
=
cJSON_GetObjectItem
(
patch
,
"value"
);
value
=
get_object_item
(
patch
,
"value"
,
case_sensitive
);
if
(
value
==
NULL
)
{
/* missing "value" for add/replace. */
...
...
@@ -714,7 +724,7 @@ static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_
/* Copy/Move uses "from". */
if
((
opcode
==
MOVE
)
||
(
opcode
==
COPY
))
{
cJSON
*
from
=
cJSON_GetObjectItem
(
patch
,
"from"
);
cJSON
*
from
=
get_object_item
(
patch
,
"from"
,
case_sensitive
);
if
(
from
==
NULL
)
{
/* missing "from" for copy/move. */
...
...
@@ -749,7 +759,7 @@ static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_
}
else
/* Add/Replace uses "value". */
{
value
=
cJSON_GetObjectItem
(
patch
,
"value"
);
value
=
get_object_item
(
patch
,
"value"
,
case_sensitive
);
if
(
value
==
NULL
)
{
/* missing "value" for add/replace. */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录