Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mdmngr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IOPSYS
mdmngr
Commits
01f2ec83
Commit
01f2ec83
authored
7 years ago
by
Arun Muthusamy
Browse files
Options
Downloads
Patches
Plain Diff
update function get_json_string_object_by_key
parent
deecbab3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common.c
+18
-29
18 additions, 29 deletions
common.c
common.h
+1
-1
1 addition, 1 deletion
common.h
with
19 additions
and
30 deletions
common.c
+
18
−
29
View file @
01f2ec83
...
@@ -52,38 +52,27 @@ struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb)
...
@@ -52,38 +52,27 @@ struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb)
return
bb
;
return
bb
;
}
}
//free memory "return_object"
struct
json_object
*
get_json_string_object_by_key
(
json_object
*
json_obj
,
char
*
string
)
struct
json_object
*
json_parse_string
(
json_object
*
jsonContainer
,
char
*
string
)
{
{
json_object_iter
iterator
;
json_object_iter
iterator
;
json_object
*
return_object
;
json_object
*
string_object
=
NULL
;
enum
json_type
type
;
enum
json_type
type
;
int
string_found
=
0
;
type
=
json_object_get_type
(
json_obj
);
type
=
json_object_get_type
(
jsonContainer
);
if
(
type
==
json_type_object
)
{
if
(
type
==
json_type_object
)
{
//search the key from the json object
json_object_object_foreachC
(
jsonContainer
,
iterator
)
{
json_object_object_foreachC
(
json_obj
,
iterator
)
{
//prints the key..
printf
(
"iteratorKey is :%s
\n
"
,
iterator
.
key
);
printf
(
"iteratorKey is :%s
\n
"
,
iterator
.
key
);
if
(
strcmp
(
string
,
(
char
*
)
iterator
.
key
)
==
0
)
{
if
(
strcmp
(
string
,
(
char
*
)
iterator
.
key
)
==
0
)
{
string_object
=
json_object_object_get
(
json_obj
,
iterator
.
key
);
return_object
=
json_object_object_get
(
jsonContainer
,
iterator
.
key
);
printf
(
"Input string value: %s
\n
"
,
(
char
*
)
json_object_get_string
(
iterator
.
val
));
printf
(
"Input string value: %s
\n
"
,
(
char
*
)
json_object_get_string
(
iterator
.
val
));
break
;
string_found
=
1
;
}
break
;
}
}
}
}
return
string_object
;
}
if
(
string_found
)
return
return_object
;
else
goto
string_not_found
;
fail_calloc:
string_not_found:
return
NULL
;
}
}
void
xml_to_json
(
xmlNode
*
anode
,
json_object
*
jobj
)
void
xml_to_json
(
xmlNode
*
anode
,
json_object
*
jobj
)
{
{
xmlNodePtr
cur_node
=
NULL
;
xmlNodePtr
cur_node
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
common.h
+
1
−
1
View file @
01f2ec83
...
@@ -82,5 +82,5 @@ int validate_puk_format(char *puk);
...
@@ -82,5 +82,5 @@ int validate_puk_format(char *puk);
int
validate_pin_format
(
char
*
pin
);
int
validate_pin_format
(
char
*
pin
);
int
pin_status
(
struct
blob_buf
*
bb
,
struct
device
*
dev
);
int
pin_status
(
struct
blob_buf
*
bb
,
struct
device
*
dev
);
int
check_response
(
struct
json_object
*
response
);
int
check_response
(
struct
json_object
*
response
);
struct
json_object
*
json_
parse_
string
(
json_object
*
json
Container
,
char
*
string
);
struct
json_object
*
get_
json_string
_object_by_key
(
json_object
*
json
_obj
,
char
*
string
);
#endif
#endif
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