Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
850d857a
Commit
850d857a
authored
Feb 14, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JSON utility improvement
parent
c1f7cc22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
0 deletions
+75
-0
src/utils/json.cpp
src/utils/json.cpp
+56
-0
src/utils/json.hpp
src/utils/json.hpp
+19
-0
No files found.
src/utils/json.cpp
View file @
850d857a
...
@@ -360,3 +360,59 @@ Json Json::Obj(std::initializer_list<std::pair<std::string, Json>> &&elements)
...
@@ -360,3 +360,59 @@ Json Json::Obj(std::initializer_list<std::pair<std::string, Json>> &&elements)
json
.
m_children
[
item
.
first
]
=
item
.
second
;
json
.
m_children
[
item
.
first
]
=
item
.
second
;
return
json
;
return
json
;
}
}
Json
ToJson
(
nullptr_t
)
{
return
nullptr
;
}
Json
ToJson
(
bool
v
)
{
return
v
;
}
Json
ToJson
(
const
std
::
string
&
v
)
{
return
v
;
}
Json
ToJson
(
const
char
*
v
)
{
return
v
;
}
Json
ToJson
(
uint8_t
v
)
{
return
v
;
}
Json
ToJson
(
int8_t
v
)
{
return
v
;
}
Json
ToJson
(
uint16_t
v
)
{
return
v
;
}
Json
ToJson
(
int16_t
v
)
{
return
v
;
}
Json
ToJson
(
uint32_t
v
)
{
return
v
;
}
Json
ToJson
(
int32_t
v
)
{
return
v
;
}
Json
ToJson
(
int64_t
v
)
{
return
v
;
}
src/utils/json.hpp
View file @
850d857a
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <initializer_list>
#include <initializer_list>
#include <map>
#include <map>
#include <optional>
#include <string>
#include <string>
#include <utility>
#include <utility>
...
@@ -84,3 +85,21 @@ class Json
...
@@ -84,3 +85,21 @@ class Json
[[
nodiscard
]]
std
::
string
dumpJson
()
const
;
[[
nodiscard
]]
std
::
string
dumpJson
()
const
;
[[
nodiscard
]]
std
::
string
dumpYaml
()
const
;
[[
nodiscard
]]
std
::
string
dumpYaml
()
const
;
};
};
Json
ToJson
(
nullptr_t
);
Json
ToJson
(
bool
v
);
Json
ToJson
(
const
std
::
string
&
v
);
Json
ToJson
(
const
char
*
v
);
Json
ToJson
(
uint8_t
v
);
Json
ToJson
(
int8_t
v
);
Json
ToJson
(
uint16_t
v
);
Json
ToJson
(
int16_t
v
);
Json
ToJson
(
uint32_t
v
);
Json
ToJson
(
int32_t
v
);
Json
ToJson
(
int64_t
v
);
template
<
typename
T
>
inline
Json
ToJson
(
const
std
::
optional
<
T
>
&
v
)
{
return
v
.
has_value
()
?
ToJson
(
*
v
)
:
Json
{
nullptr
};
}
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