Browse Source

Util: Add user-defined string literal for Json::Value

master
Riyyi 2 years ago
parent
commit
0841e49b46
  1. 12
      src/util/json/value.h

12
src/util/json/value.h

@ -7,7 +7,7 @@
#ifndef JSON_VALUE_H
#define JSON_VALUE_H
#include <cstddef> // nullptr_t
#include <cstddef> // nullptr_t, size_t
#include <cstdint> // uint32_t
#include <initializer_list>
#include <iostream> // istream, ostream
@ -129,4 +129,14 @@ std::ostream& operator<<(std::ostream& output, const Value& value);
} // namespace Json
/**
* User-defined string literal
*
* Example usage: auto json = "[ 3.14, true, null ]"_json;
*/
inline Json::Value operator"" _json(const char* input, size_t length)
{
return Json::Value::parse(std::string(input, length));
}
#endif // JSON_VALUE_H

Loading…
Cancel
Save