userver: formats::json Namespace Reference
Loading...
Searching...
No Matches
formats::json Namespace Reference

Detailed Description

JSON support.

Namespaces

namespace  blocking
 
namespace  parser
 SAX parser tools.
 

Classes

class  BadStreamException
 
class  ConversionException
 Conversion error. More...
 
class  Exception
 
class  ExceptionWithPath
 
class  Iterator
 Iterator for formats::json::Value More...
 
class  MemberMissingException
 
class  OutOfBoundsException
 
class  ParseException
 
struct  PrettyFormat
 
class  Schema
 
class  StringBuilder
 SAX like builder of JSON string. Use with extreme caution and only in performance critical part of your code. More...
 
class  TypeMismatchException
 
class  UnknownDiscriminatorException
 
class  Value
 Non-mutable JSON value representation. More...
 
class  ValueBuilder
 Builder for JSON. More...
 

Functions

template<typename... Args>
Value MakeObject (Args &&...)
 
template<typename... Args>
Value MakeArray (Args &&...)
 
formats::json::Value FromString (std::string_view doc)
 Parse JSON from string.
 
formats::json::Value FromStream (std::istream &is)
 Parse JSON from stream.
 
void Serialize (const formats::json::Value &doc, std::ostream &os)
 Serialize JSON to stream.
 
std::string ToString (const formats::json::Value &doc)
 Serialize JSON to string.
 
std::string ToStableString (const formats::json::Value &doc)
 
std::string ToStableString (formats::json::Value &&doc)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::string ToPrettyString (const formats::json::Value &doc, PrettyFormat format={})
 Serialize JSON to a string, using \n and indents for objects and arrays.
 
logging::LogHelperoperator<< (logging::LogHelper &, const formats::json::Value &)
 Log JSON.
 
void WriteToStream (bool value, StringBuilder &sw)
 
void WriteToStream (long long value, StringBuilder &sw)
 
void WriteToStream (unsigned long long value, StringBuilder &sw)
 
void WriteToStream (int value, StringBuilder &sw)
 
void WriteToStream (unsigned value, StringBuilder &sw)
 
void WriteToStream (long value, StringBuilder &sw)
 
void WriteToStream (unsigned long value, StringBuilder &sw)
 
void WriteToStream (double value, StringBuilder &sw)
 
void WriteToStream (const char *value, StringBuilder &sw)
 
void WriteToStream (std::string_view value, StringBuilder &sw)
 
void WriteToStream (const formats::json::Value &value, StringBuilder &sw)
 
void WriteToStream (const std::string &value, StringBuilder &sw)
 
void WriteToStream (std::chrono::system_clock::time_point tp, StringBuilder &sw)
 
bool Validate (const formats::json::Value &doc, const formats::json::Schema &schema)
 
bool Parse (const Value &value, parse::To< bool >)
 
std::int64_t Parse (const Value &value, parse::To< std::int64_t >)
 
std::uint64_t Parse (const Value &value, parse::To< std::uint64_t >)
 
double Parse (const Value &value, parse::To< double >)
 
std::string Parse (const Value &value, parse::To< std::string >)
 
template<>
std::string Value::ConvertTo< std::string > () const
 
Value Parse (const Value &value, parse::To< Value >)
 
std::chrono::microseconds Parse (const Value &value, parse::To< std::chrono::microseconds >)
 
std::chrono::milliseconds Parse (const Value &value, parse::To< std::chrono::milliseconds >)
 
std::chrono::minutes Parse (const Value &value, parse::To< std::chrono::minutes >)
 
std::chrono::hours Parse (const Value &value, parse::To< std::chrono::hours >)
 
template<typename T >
std::enable_if_t< std::is_integral< T >::value &&sizeof(T)<=sizeof(int64_t), ValueSerialize (T value, formats::serialize::To< Value >)
 
json::Value Serialize (std::chrono::system_clock::time_point tp, formats::serialize::To< Value >)
 
template<typename T >
std::enable_if_t< meta::kIsUniqueMap< T > &&utils::IsStrongTypedefLoggable(T::key_type::kOps), ValueSerialize (const T &value, formats::serialize::To< Value >)
 Optimized maps of StrongTypedefs serialization for JSON.
 
template<typename T >
std::enable_if_t< meta::kIsUniqueMap< T > &&std::is_convertible_v< typename T::key_type, std::string >, ValueSerialize (const T &value, formats::serialize::To< Value >)
 Optimized maps serialization for JSON.
 
void PrintTo (const Value &, std::ostream *)
 

Variables

constexpr std::size_t kDepthParseLimit = 128
 

Function Documentation

◆ Parse()

Value formats::json::Parse ( const Value & value,
parse::To< Value >  )
inline

Definition at line 417 of file value.hpp.

◆ Serialize() [1/3]

template<typename T >
std::enable_if_t< meta::kIsUniqueMap< T > && utils::IsStrongTypedefLoggable(T::key_type::kOps), Value > formats::json::Serialize ( const T & value,
formats::serialize::To< Value >  )

Optimized maps of StrongTypedefs serialization for JSON.

Definition at line 239 of file value_builder.hpp.

◆ Serialize() [2/3]

template<typename T >
std::enable_if_t< meta::kIsUniqueMap< T > && std::is_convertible_v< typename T::key_type, std::string >, Value > formats::json::Serialize ( const T & value,
formats::serialize::To< Value >  )

Optimized maps serialization for JSON.

Definition at line 252 of file value_builder.hpp.

◆ Serialize() [3/3]

template<typename T >
std::enable_if_t< std::is_integral< T >::value &&sizeof(T)<=sizeof(int64_t), Value > formats::json::Serialize ( T value,
formats::serialize::To< Value >  )

Definition at line 220 of file value_builder.hpp.

◆ ToStableString()

std::string formats::json::ToStableString ( const formats::json::Value & doc)

Stably serialize JSON to string. In result there is no whitespace, keys are sorted and character escaping is stabilized

Variable Documentation

◆ kDepthParseLimit

constexpr std::size_t formats::json::kDepthParseLimit = 128
inlineconstexpr

Definition at line 25 of file serialize.hpp.