WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
wpi::util::json Class Reference

#include <wpi/util/json.hpp>

Public Types

enum class  Type {
  Null , Bool , Int , Uint ,
  Float , Double , String , Array ,
  Object
}
using array_t = std::vector<json>
using object_t = wpi::util::StringMap<json>

Public Member Functions

 json (const json &)
 json (json &&)
 json (const char *)
 json (const std::string &)
 json (std::string_view)
 ~json ()
constexpr json (const std::nullptr_t=nullptr)
constexpr json (std::same_as< bool > auto value)
constexpr json (int value)
constexpr json (float value)
constexpr json (unsigned value)
constexpr json (long value)
constexpr json (unsigned long value)
constexpr json (long long value)
constexpr json (unsigned long long value)
constexpr json (double value)
 json (std::string &&value)
 json (array_t &&value)
 json (object_t &&value)
template<std::ranges::input_range R>
requires detail::JsonConvertible<std::ranges::range_value_t<R>>
 json (const R &range)
template<detail::HasToJson T>
 json (const T &value)
template<detail::HasJsonSerializer T>
 json (const T &value)
constexpr Type type () const
constexpr bool is_null () const
constexpr bool is_bool () const
constexpr bool is_number () const
constexpr bool is_int () const
constexpr bool is_uint () const
constexpr bool is_float () const
constexpr bool is_double () const
bool is_string () const
bool is_array () const
bool is_object () const
bool get_bool () const
float get_float () const
double get_double () const
double get_number () const
long long get_int () const
unsigned long long get_uint () const
std::string & get_string ()
const std::string & get_string () const
array_tget_array ()
const array_tget_array () const
object_tget_object ()
const object_tget_object () const
template<detail::HasFromJson T>
get () const
template<detail::HasJsonDeserializer T>
get () const
bool contains (std::string_view) const
jsonlookup (std::string_view)
const jsonlookup (std::string_view) const
void set_array ()
void set_object ()
std::string to_string () const
std::string to_string_pretty () const
jsonoperator= (const json &)
jsonoperator= (json &&)
template<detail::HasToJson T>
jsonoperator= (const T &value)
template<detail::HasJsonSerializer T>
jsonoperator= (const T &value)
jsonoperator[] (size_t)
jsonoperator[] (std::string_view)
jsonat (size_t)
jsonat (std::string_view)
const jsonat (size_t) const
const jsonat (std::string_view) const
json value (size_t, json &&)
json value (std::string_view, json &&)
void erase (std::string_view)
jsonemplace_back (json &&value)
bool empty () const
 operator std::string () const
void marshal (wpi::util::raw_ostream &os, bool pretty=false, int indent=0) const

Static Public Member Functions

static wpi::util::expected< json, const char * > parse (std::string_view)
static json parse_or_throw (std::string_view)
template<typename... Args>
static json array (Args &&... args)
template<typename... Args>
static json object (Args &&... args)
static void stringify_null (wpi::util::raw_ostream &)
static void stringify_string (wpi::util::raw_ostream &, std::string_view)
static void stringify_bool (wpi::util::raw_ostream &, bool)
static void stringify_float (wpi::util::raw_ostream &, float)
static void stringify_double (wpi::util::raw_ostream &, double)
static void stringify_int (wpi::util::raw_ostream &, long long)
static void stringify_uint (wpi::util::raw_ostream &, unsigned long long)
static void stringify_array (wpi::util::raw_ostream &, const array_t &, bool pretty=false, int indent=0)
static void stringify_object (wpi::util::raw_ostream &, const object_t &, bool pretty=false, int indent=0)

Friends

bool operator== (const json &lhs, const json &rhs)

Member Typedef Documentation

◆ array_t

using wpi::util::json::array_t = std::vector<json>

◆ object_t

Member Enumeration Documentation

◆ Type

enum class wpi::util::json::Type
strong
Enumerator
Null 
Bool 
Int 
Uint 
Float 
Double 
String 
Array 
Object 

Constructor & Destructor Documentation

◆ json() [1/21]

wpi::util::json::json ( const json & )

◆ json() [2/21]

wpi::util::json::json ( json && )

◆ json() [3/21]

wpi::util::json::json ( const char * )

◆ json() [4/21]

wpi::util::json::json ( const std::string & )

◆ json() [5/21]

wpi::util::json::json ( std::string_view )

◆ ~json()

wpi::util::json::~json ( )

◆ json() [6/21]

wpi::util::json::json ( const std::nullptr_t = nullptr)
inlineconstexpr

◆ json() [7/21]

wpi::util::json::json ( std::same_as< bool > auto value)
inlineconstexpr

◆ json() [8/21]

wpi::util::json::json ( int value)
inlineconstexpr

◆ json() [9/21]

wpi::util::json::json ( float value)
inlineconstexpr

◆ json() [10/21]

wpi::util::json::json ( unsigned value)
inlineconstexpr

◆ json() [11/21]

wpi::util::json::json ( long value)
inlineconstexpr

◆ json() [12/21]

wpi::util::json::json ( unsigned long value)
inlineconstexpr

◆ json() [13/21]

wpi::util::json::json ( long long value)
inlineconstexpr

◆ json() [14/21]

wpi::util::json::json ( unsigned long long value)
inlineconstexpr

◆ json() [15/21]

wpi::util::json::json ( double value)
inlineconstexpr

◆ json() [16/21]

wpi::util::json::json ( std::string && value)
inline

◆ json() [17/21]

wpi::util::json::json ( array_t && value)
inline

◆ json() [18/21]

wpi::util::json::json ( object_t && value)
inline

◆ json() [19/21]

template<std::ranges::input_range R>
requires detail::JsonConvertible<std::ranges::range_value_t<R>>
wpi::util::json::json ( const R & range)
inline

◆ json() [20/21]

template<detail::HasToJson T>
wpi::util::json::json ( const T & value)
inline

◆ json() [21/21]

template<detail::HasJsonSerializer T>
wpi::util::json::json ( const T & value)
inline

Member Function Documentation

◆ array()

template<typename... Args>
json wpi::util::json::array ( Args &&... args)
inlinestatic

◆ at() [1/4]

json & wpi::util::json::at ( size_t )

◆ at() [2/4]

const json & wpi::util::json::at ( size_t ) const

◆ at() [3/4]

json & wpi::util::json::at ( std::string_view )

◆ at() [4/4]

const json & wpi::util::json::at ( std::string_view ) const

◆ contains()

bool wpi::util::json::contains ( std::string_view ) const

◆ emplace_back()

json & wpi::util::json::emplace_back ( json && value)

◆ empty()

bool wpi::util::json::empty ( ) const

◆ erase()

void wpi::util::json::erase ( std::string_view )

◆ get() [1/2]

template<detail::HasJsonDeserializer T>
T wpi::util::json::get ( ) const
inline

◆ get() [2/2]

template<detail::HasFromJson T>
T wpi::util::json::get ( ) const
inline

◆ get_array() [1/2]

array_t & wpi::util::json::get_array ( )

◆ get_array() [2/2]

const array_t & wpi::util::json::get_array ( ) const

◆ get_bool()

bool wpi::util::json::get_bool ( ) const

◆ get_double()

double wpi::util::json::get_double ( ) const

◆ get_float()

float wpi::util::json::get_float ( ) const

◆ get_int()

long long wpi::util::json::get_int ( ) const

◆ get_number()

double wpi::util::json::get_number ( ) const

◆ get_object() [1/2]

object_t & wpi::util::json::get_object ( )

◆ get_object() [2/2]

const object_t & wpi::util::json::get_object ( ) const

◆ get_string() [1/2]

std::string & wpi::util::json::get_string ( )

◆ get_string() [2/2]

const std::string & wpi::util::json::get_string ( ) const

◆ get_uint()

unsigned long long wpi::util::json::get_uint ( ) const

◆ is_array()

bool wpi::util::json::is_array ( ) const
inline

◆ is_bool()

bool wpi::util::json::is_bool ( ) const
inlineconstexpr

◆ is_double()

bool wpi::util::json::is_double ( ) const
inlineconstexpr

◆ is_float()

bool wpi::util::json::is_float ( ) const
inlineconstexpr

◆ is_int()

bool wpi::util::json::is_int ( ) const
inlineconstexpr

◆ is_null()

bool wpi::util::json::is_null ( ) const
inlineconstexpr

◆ is_number()

bool wpi::util::json::is_number ( ) const
inlineconstexpr

◆ is_object()

bool wpi::util::json::is_object ( ) const
inline

◆ is_string()

bool wpi::util::json::is_string ( ) const
inline

◆ is_uint()

bool wpi::util::json::is_uint ( ) const
inlineconstexpr

◆ lookup() [1/2]

json * wpi::util::json::lookup ( std::string_view )

◆ lookup() [2/2]

const json * wpi::util::json::lookup ( std::string_view ) const

◆ marshal()

void wpi::util::json::marshal ( wpi::util::raw_ostream & os,
bool pretty = false,
int indent = 0 ) const

◆ object()

template<typename... Args>
json wpi::util::json::object ( Args &&... args)
inlinestatic

◆ operator std::string()

wpi::util::json::operator std::string ( ) const
inline

◆ operator=() [1/4]

json & wpi::util::json::operator= ( const json & )

◆ operator=() [2/4]

template<detail::HasJsonSerializer T>
json & wpi::util::json::operator= ( const T & value)
inline

◆ operator=() [3/4]

template<detail::HasToJson T>
json & wpi::util::json::operator= ( const T & value)
inline

◆ operator=() [4/4]

json & wpi::util::json::operator= ( json && )

◆ operator[]() [1/2]

json & wpi::util::json::operator[] ( size_t )

◆ operator[]() [2/2]

json & wpi::util::json::operator[] ( std::string_view )

◆ parse()

wpi::util::expected< json, const char * > wpi::util::json::parse ( std::string_view )
static

◆ parse_or_throw()

json wpi::util::json::parse_or_throw ( std::string_view )
static

◆ set_array()

void wpi::util::json::set_array ( )

◆ set_object()

void wpi::util::json::set_object ( )

◆ stringify_array()

void wpi::util::json::stringify_array ( wpi::util::raw_ostream & ,
const array_t & ,
bool pretty = false,
int indent = 0 )
static

◆ stringify_bool()

void wpi::util::json::stringify_bool ( wpi::util::raw_ostream & ,
bool  )
static

◆ stringify_double()

void wpi::util::json::stringify_double ( wpi::util::raw_ostream & ,
double  )
static

◆ stringify_float()

void wpi::util::json::stringify_float ( wpi::util::raw_ostream & ,
float  )
static

◆ stringify_int()

void wpi::util::json::stringify_int ( wpi::util::raw_ostream & ,
long long  )
static

◆ stringify_null()

void wpi::util::json::stringify_null ( wpi::util::raw_ostream & )
static

◆ stringify_object()

void wpi::util::json::stringify_object ( wpi::util::raw_ostream & ,
const object_t & ,
bool pretty = false,
int indent = 0 )
static

◆ stringify_string()

void wpi::util::json::stringify_string ( wpi::util::raw_ostream & ,
std::string_view  )
static

◆ stringify_uint()

void wpi::util::json::stringify_uint ( wpi::util::raw_ostream & ,
unsigned long long  )
static

◆ to_string()

std::string wpi::util::json::to_string ( ) const

◆ to_string_pretty()

std::string wpi::util::json::to_string_pretty ( ) const

◆ type()

Type wpi::util::json::type ( ) const
inlineconstexpr

◆ value() [1/2]

json wpi::util::json::value ( size_t ,
json &&  )

◆ value() [2/2]

json wpi::util::json::value ( std::string_view ,
json &&  )

◆ operator==

bool operator== ( const json & lhs,
const json & rhs )
friend

Member Data Documentation

◆ array_value

array_t wpi::util::json::array_value

◆ bool_value

bool wpi::util::json::bool_value

◆ double_value

double wpi::util::json::double_value

◆ float_value

float wpi::util::json::float_value

◆ long_value

long long wpi::util::json::long_value

◆ object_value

object_t wpi::util::json::object_value

◆ string_value

std::string wpi::util::json::string_value

◆ ulong_value

unsigned long long wpi::util::json::ulong_value

The documentation for this class was generated from the following file: