Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alexander Lapshin
common
Commits
ec8211d5
Commit
ec8211d5
authored
Jun 22, 2021
by
Alexander Lapshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ae1ed348
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
json_functions.h
json/json_functions.h
+22
-0
No files found.
json/json_functions.h
View file @
ec8211d5
...
...
@@ -260,6 +260,28 @@ template <typename T> bool loadjson(const jsonval& parent, std::string key, T& i
return
true
;
}
template
<
typename
T
>
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
svalue
<
T
>&
value
,
const
bool
exist
=
true
)
{
jsonval
::
ConstMemberIterator
itr
;
bool
*
loaded
=
nullptr
;
if
(
!
extract_value
(
parent
,
key
,
exist
,
loaded
,
itr
))
{
return
false
;
}
const
jsonval
&
a
=
itr
->
value
;
if
(
!
a
.
IsObject
())
{
throw
Exp
()
<<
"error: element is not an object"
;
}
T
val
;
val
.
load
(
itr
->
value
);
value
=
val
;
return
true
;
}
template
<
typename
T
>
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
T
&
item
,
const
bool
exist
=
true
,
bool
*
loaded
=
nullptr
)
{
jsonval
::
ConstMemberIterator
itr
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment