Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dap-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dap
dap-sdk
Commits
9ce1011a
Commit
9ce1011a
authored
6 months ago
by
alexey.stratulat
Browse files
Options
Downloads
Patches
Plain Diff
[*] Fixed json_object list output now the amount of indentation is correct.
parent
13684a1f
No related branches found
Branches containing commit
No related tags found
2 merge requests
!402
Master 2809
,
!381
Bugfix 12474
Pipeline
#44439
passed with stage
Stage: build
in 17 minutes and 33 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
net/server/json_rpc/rpc_core/src/dap_json_rpc_response.c
+8
-20
8 additions, 20 deletions
net/server/json_rpc/rpc_core/src/dap_json_rpc_response.c
with
8 additions
and
20 deletions
net/server/json_rpc/rpc_core/src/dap_json_rpc_response.c
+
8
−
20
View file @
9ce1011a
#include
"dap_json_rpc_response.h"
#define LOG_TAG "dap_json_rpc_response"
#define INDENTATION_LEVEL " "
dap_json_rpc_response_t
*
dap_json_rpc_response_init
()
{
...
...
@@ -231,7 +232,7 @@ void json_print_object(json_object *obj, int indent_level) {
case
json_type_object
:
{
json_object_object_foreach
(
obj
,
key
,
val
)
{
for
(
int
i
=
0
;
i
<=
indent_level
;
i
++
)
{
printf
(
" "
);
// indentation level
printf
(
INDENTATION_LEVEL
);
// indentation level
}
printf
(
"%s: "
,
key
);
json_print_value
(
val
,
key
,
indent_level
+
1
,
false
);
...
...
@@ -242,10 +243,13 @@ void json_print_object(json_object *obj, int indent_level) {
case
json_type_array
:
{
int
length
=
json_object_array_length
(
obj
);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
for
(
int
j
=
0
;
j
<=
indent_level
;
j
++
)
{
printf
(
INDENTATION_LEVEL
);
// indentation level
}
json_object
*
item
=
json_object_array_get_idx
(
obj
,
i
);
json_print_value
(
item
,
NULL
,
indent_level
+
1
,
length
-
1
-
i
);
printf
(
"
\n
"
);
}
printf
(
"
\n
"
);
break
;
}
default:
...
...
@@ -349,24 +353,8 @@ int dap_json_rpc_response_printf_result(dap_json_rpc_response_t* response, char
switch
(
json_print_commands
(
cmd_name
))
{
case
1
:
json_print_for_tx_history
(
response
);
break
;
return
0
;
// case 2: json_print_for_mempool_list(response); break; return 0;
default:
{
int
json_type
=
0
;
json_object_is_type
(
response
->
result_json_object
,
json_type
);
if
(
json_type
==
json_type_array
)
{
/* print json array */
int
result_count
=
json_object_array_length
(
response
->
result_json_object
);
if
(
result_count
<=
0
)
{
printf
(
"response json array length is 0
\n
"
);
return
-
3
;
}
for
(
int
i
=
0
;
i
<
result_count
;
i
++
)
{
struct
json_object
*
json_obj_result
=
json_object_array_get_idx
(
response
->
result_json_object
,
i
);
json_print_object
(
json_obj_result
,
0
);
printf
(
"
\n
"
);
json_object_put
(
json_obj_result
);
}
}
else
{
/* print json */
json_print_object
(
response
->
result_json_object
,
0
);
}
default:
{
/* print json */
json_print_object
(
response
->
result_json_object
,
0
);
}
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment