Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from levavakian/allow-nan-inf
Browse files Browse the repository at this point in the history
Allow rapidjson writer to handle nan and inf values
  • Loading branch information
facontidavide authored Oct 16, 2020
2 parents 17d60f9 + 76a10ac commit f874a6f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/ros_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,21 @@ bool Parser::deserializeIntoJson(Span<const uint8_t> buffer, std::string* json_t
json_buffer.Reserve(2048);

if( pretty_printer ){
rapidjson::PrettyWriter<rapidjson::StringBuffer> json_writer(json_buffer);
rapidjson::PrettyWriter<rapidjson::StringBuffer,
rapidjson::UTF8<>,
rapidjson::UTF8<>,
rapidjson::CrtAllocator,
rapidjson::kWriteDefaultFlags |
rapidjson::kWriteNanAndInfFlag> json_writer(json_buffer);
json_document.Accept(json_writer);
}
else{
rapidjson::Writer<rapidjson::StringBuffer> json_writer(json_buffer);
rapidjson::Writer<rapidjson::StringBuffer,
rapidjson::UTF8<>,
rapidjson::UTF8<>,
rapidjson::CrtAllocator,
rapidjson::kWriteDefaultFlags |
rapidjson::kWriteNanAndInfFlag> json_writer(json_buffer);
json_document.Accept(json_writer);
}
*json_txt = json_buffer.GetString();
Expand Down

0 comments on commit f874a6f

Please sign in to comment.