Commit 471e3d68 authored by Emmanuel Papillon's avatar Emmanuel Papillon
Browse files

update json reader / writer to not use deprecated functions

parent fa88d920
Pipeline #41568 failed with stages
in 6 minutes and 54 seconds
......@@ -272,7 +272,7 @@ void CurlLoop::quit()
Lock alock(&m_lock);
m_quit = true;
write(m_pipes[1],"|",1);
ssize_t w = write(m_pipes[1],"|",1);
pthread_cond_broadcast(&m_cond);
alock.unLock();
......
......@@ -424,10 +424,13 @@ size_t Requests::Command::_write_callback(char *ptr,size_t size,
int Requests::Command::get_serie_id()
{
Json::Value root;
Json::Reader reader;
if(!reader.parse(m_data,root))
THROW_EIGER_EXCEPTION(eigerapi::JSON_PARSE_FAILED,"");
Json::Value root;
Json::CharReaderBuilder rbuilder;
std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
std::string errs;
if (!reader->parse(m_data, m_data+strlen(m_data), &root, &errs))
THROW_EIGER_EXCEPTION(eigerapi::JSON_PARSE_FAILED, errs.c_str());
int seq_id = root.get("sequence id", -1).asInt();
return seq_id;
......@@ -472,10 +475,13 @@ Requests::Param::Value Requests::Param::_get(double timeout,bool lock,
//- Json decoding to return the wanted data
Json::Value root;
Json::Reader reader;
Json::CharReaderBuilder rbuilder;
std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
std::string errs;
if (!reader->parse(m_data_buffer, m_data_buffer+m_data_size, &root, &errs))
THROW_EIGER_EXCEPTION(eigerapi::JSON_PARSE_FAILED, errs.c_str());
if (!reader.parse(m_data_buffer, root))
THROW_EIGER_EXCEPTION(eigerapi::JSON_PARSE_FAILED,"");
Value value;
std::string json_type;
bool is_list = root.isArray() || root.get(param_name, "no_value").isArray();
......@@ -561,8 +567,9 @@ void Requests::Param::_fill_set_request(const T& value)
{
Json::Value root;
root["value"] = value;
Json::FastWriter writer;
std::string json_struct = writer.write(root);
Json::StreamWriterBuilder wbuilder;
std::string json_struct = Json::writeString(wbuilder, root);
m_headers = curl_slist_append(m_headers, "Accept: application/json");
m_headers = curl_slist_append(m_headers, "Content-Type: application/json;charset=utf-8");
......
......@@ -170,9 +170,11 @@ inline Json::Value Stream::_ZmqThread::_get_json_header(MessagePtr &msg)
const char* begin = (const char*)data;
const char* end = begin + data_size;
Json::Value header;
Json::Reader reader;
if (!reader.parse(begin,end,header))
THROW_HW_ERROR(Error) << "Error parsing header: " << std::string(begin, end);
Json::CharReaderBuilder rbuilder;
std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
std::string errs;
if (!reader->parse(begin, end, &header, &errs))
THROW_HW_ERROR(Error) << "Error parsing header: " << errs;
return header;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment