-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxjson_proc.cpp
More file actions
44 lines (40 loc) · 1.24 KB
/
xjson_proc.cpp
File metadata and controls
44 lines (40 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2017-2018 Telos Foundation & contributors
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "xjson_proc.h"
namespace top
{
namespace httpserver
{
bool xjson_proc::parse_json(const std::string& str_content)
{
if (!m_reader.parse(str_content, m_request_json))
{
SET_RESPONSE_CODE(xhttp_error_code::json_parser_error)
return false;
}
if(m_request_json["action"].isNull())
{
SET_RESPONSE_CODE(xhttp_error_code::action_not_find)
return false;
}
return true;
}
std::string xjson_proc::get_response()
{
return m_writer.write(m_response_json);
}
std::string xjson_proc::get_request()
{
return m_writer.write(m_request_json);
}
bool xjson_parse::parse_json(const std::string& str_content)
{
if (!m_reader.parse(str_content, m_json))
{
return false;
}
return true;
}
}
}