496 {
497 if (
obj.type() ==
typeid(map<string, boost::any>)) {
498 string jsonStr = "{ ";
499 Size i = 0;
500 for (
const auto& kv : boost::any_cast<map<string, boost::any>>(
obj)) {
501 if (i > 0)
502 jsonStr += ", ";
503 jsonStr +=
'\"' + kv.first +
"\": " +
jsonify(kv.second);
504 i++;
505 }
506 jsonStr += " }";
507 return jsonStr;
508 }
else if (
obj.type() ==
typeid(vector<boost::any>)) {
509 string arrayStr = "[ ";
510 Size i = 0;
511 for (
const auto& v : boost::any_cast<vector<boost::any>>(
obj)) {
512 if (i > 0)
513 arrayStr += ", ";
515 i++;
516 }
517 arrayStr += " ]";
518 return arrayStr;
519 }
else if (
obj.type() ==
typeid(
string)) {
520 string str = boost::any_cast<string>(
obj);
521 boost::replace_all(str, "\\", "\\\\");
522 boost::replace_all(str, "\"", "\\\"");
523 boost::replace_all(str, "\r", "\\r");
524 boost::replace_all(str, "\n", "\\n");
525 return '\"' + str + '\"';
527 return to_string(boost::any_cast<StructuredMessage::Category>(
obj));
529 return to_string(boost::any_cast<StructuredMessage::Group>(
obj));
530 }
else if (
obj.type() ==
typeid(
int)) {
532 }
else if (
obj.type() ==
typeid(
bool)) {
534 }
else if (
obj.type() ==
typeid(QuantLib::Size)) {
536 }
else if (
obj.type() ==
typeid(QuantLib::Real)) {
538 }
else if (
obj.type() ==
typeid(
unsigned int)) {
540 }
else if (
obj.type() ==
typeid(
unsigned short)) {
542 }
else if (
obj.type() ==
typeid(
float)) {
544 } else {
545 try {
546
547 StructuredLoggingErrorMessage("JSON Message Logging", "JSONMessage::jsonify() : Unrecognised value type")
548 .log();
549 } catch (...) {
550 }
551 return string();
552 }
553}
std::string to_string(const LocationInfo &l)