Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_takeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanghui.cui
familyMart_takeaway
Commits
9a50462f
Commit
9a50462f
authored
Mar 05, 2019
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json添加 null 判断,防止访问null程序崩溃
parent
d14f35eb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
src/JsonModule.cpp
+13
-4
src/main.cpp
+2
-2
No files found.
src/JsonModule.cpp
View file @
9a50462f
...
@@ -71,34 +71,43 @@ JsonModule::~JsonModule()
...
@@ -71,34 +71,43 @@ JsonModule::~JsonModule()
const
char
*
GetJsonStringSafe
(
rapidjson
::
Value
&
obj
,
const
char
*
key
)
const
char
*
GetJsonStringSafe
(
rapidjson
::
Value
&
obj
,
const
char
*
key
)
{
{
if
(
obj
.
HasMember
(
key
)){
if
(
!
obj
.
IsNull
())
{
if
(
obj
.
HasMember
(
key
))
{
rapidjson
::
Value
&
vObj
=
obj
[
key
];
rapidjson
::
Value
&
vObj
=
obj
[
key
];
if
(
vObj
.
IsString
())
{
if
(
vObj
.
IsString
())
{
return
vObj
.
GetString
();
return
vObj
.
GetString
();
}
}
}
}
}
return
""
;
return
""
;
}
}
int
GetJsonIntSafe
(
rapidjson
::
Value
&
obj
,
const
char
*
key
)
int
GetJsonIntSafe
(
rapidjson
::
Value
&
obj
,
const
char
*
key
)
{
{
if
(
obj
.
HasMember
(
key
)){
if
(
!
obj
.
IsNull
())
{
if
(
obj
.
HasMember
(
key
))
{
rapidjson
::
Value
&
vObj
=
obj
[
key
];
rapidjson
::
Value
&
vObj
=
obj
[
key
];
if
(
vObj
.
IsInt
())
{
if
(
vObj
.
IsInt
())
{
return
vObj
.
GetInt
();
return
vObj
.
GetInt
();
}
}
}
}
}
return
0
;
return
0
;
}
}
int64_t
GetJsonInt64Safe
(
rapidjson
::
Value
&
obj
,
const
char
*
key
)
int64_t
GetJsonInt64Safe
(
rapidjson
::
Value
&
obj
,
const
char
*
key
)
{
{
if
(
!
obj
.
IsNull
())
{
if
(
obj
.
HasMember
(
key
))
{
if
(
obj
.
HasMember
(
key
))
{
rapidjson
::
Value
&
vObj
=
obj
[
key
];
rapidjson
::
Value
&
vObj
=
obj
[
key
];
if
(
vObj
.
IsInt64
())
{
if
(
vObj
.
IsInt64
())
{
return
vObj
.
GetInt64
();
return
vObj
.
GetInt64
();
}
}
}
}
}
return
0
;
return
0
;
}
}
...
...
src/main.cpp
View file @
9a50462f
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
INITIALIZE_EASYLOGGINGPP
INITIALIZE_EASYLOGGINGPP
#define VERSION "1.0.
7 beta 5
" //版本号
#define VERSION "1.0.
8
" //版本号
std
::
string
g_init_data
;
std
::
string
g_init_data
;
std
::
string
g_init_data_ods_back
;
std
::
string
g_init_data_ods_back
;
...
@@ -174,7 +174,7 @@ void* listen_pos_func(void* arg)
...
@@ -174,7 +174,7 @@ void* listen_pos_func(void* arg)
TCPClient
ods
;
TCPClient
ods
;
if
(
ods
.
doConnect
(
ods_recv_port
,
ods_ip
.
c_str
())
)
if
(
ods
.
doConnect
(
ods_recv_port
,
ods_ip
.
c_str
())
)
{
{
ods
.
setSocketTimeout
(
6
0
);
//设置超时
ods
.
setSocketTimeout
(
3
0
);
//设置超时
if
(
ods
.
send
(
requestOdsData
)
)
if
(
ods
.
send
(
requestOdsData
)
)
{
{
std
::
string
tmp
;
std
::
string
tmp
;
...
...
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