Loading...
Searching...
No Matches
opennn::Json Class Reference

#include <opennn/core/json.h>

Public Types

enum class  Kind {
  Null , Bool , Number , String ,
  Array , Object
}
 
using Array = std::vector<Json>
 
using Object = std::vector<std::pair<std::string, Json>>
 

Public Member Functions

 Json ()=default
 
 Json (bool new_value)
 
template<typename Int, typename = std::enable_if_t<std::is_integral_v<Int> && !std::is_same_v<Int, bool>>>
 Json (Int new_value)
 
 Json (double new_value)
 
 Json (float new_value)
 
 Json (const char *new_value)
 
 Json (const std::string &new_value)
 
 Json (std::string_view new_value)
 
Kind get_kind () const noexcept
 
bool is_null () const noexcept
 
bool is_bool () const noexcept
 
bool is_number () const noexcept
 
bool is_string () const noexcept
 
bool is_array () const noexcept
 
bool is_object () const noexcept
 
Array & as_array ()
 
const Array & as_array () const
 
Object & as_object ()
 
const Object & as_object () const
 
bool has (std::string_view key) const
 
const Json * find (std::string_view) const
 
const Json & at (std::string_view) const
 
Json & operator[] (std::string_view)
 
Json & set (std::string_view, Json)
 
void push_back (Json)
 
std::string as_string () const
 
long long as_long () const
 
double as_double () const
 
bool as_bool () const
 
std::string dump (int indent=2) const
 

Static Public Member Functions

static Json make_object ()
 
static Json make_array ()
 
static Json parse (std::string_view)
 

Member Typedef Documentation

◆ Array

using opennn::Json::Array = std::vector<Json>

◆ Object

using opennn::Json::Object = std::vector<std::pair<std::string, Json>>

Member Enumeration Documentation

◆ Kind

enum class opennn::Json::Kind
strong
Enumerator
Null 
Bool 
Number 
String 
Array 
Object 

Constructor & Destructor Documentation

◆ Json() [1/8]

opennn::Json::Json ( )
default

◆ Json() [2/8]

opennn::Json::Json ( bool new_value)
inline

◆ Json() [3/8]

template<typename Int, typename = std::enable_if_t<std::is_integral_v<Int> && !std::is_same_v<Int, bool>>>
opennn::Json::Json ( Int new_value)
inline

◆ Json() [4/8]

opennn::Json::Json ( double new_value)
inline

◆ Json() [5/8]

opennn::Json::Json ( float new_value)
inline

◆ Json() [6/8]

opennn::Json::Json ( const char * new_value)
inline

◆ Json() [7/8]

opennn::Json::Json ( const std::string & new_value)
inline

◆ Json() [8/8]

opennn::Json::Json ( std::string_view new_value)
inline

Member Function Documentation

◆ as_array() [1/2]

Array & opennn::Json::as_array ( )

◆ as_array() [2/2]

const Array & opennn::Json::as_array ( ) const

◆ as_bool()

bool opennn::Json::as_bool ( ) const

◆ as_double()

double opennn::Json::as_double ( ) const

◆ as_long()

long long opennn::Json::as_long ( ) const

◆ as_object() [1/2]

Object & opennn::Json::as_object ( )

◆ as_object() [2/2]

const Object & opennn::Json::as_object ( ) const

◆ as_string()

std::string opennn::Json::as_string ( ) const

◆ at()

const Json & opennn::Json::at ( std::string_view ) const

◆ dump()

std::string opennn::Json::dump ( int indent = 2) const

◆ find()

const Json * opennn::Json::find ( std::string_view ) const

◆ get_kind()

Kind opennn::Json::get_kind ( ) const
inlinenoexcept

◆ has()

bool opennn::Json::has ( std::string_view key) const
inline

◆ is_array()

bool opennn::Json::is_array ( ) const
inlinenoexcept

◆ is_bool()

bool opennn::Json::is_bool ( ) const
inlinenoexcept

◆ is_null()

bool opennn::Json::is_null ( ) const
inlinenoexcept

◆ is_number()

bool opennn::Json::is_number ( ) const
inlinenoexcept

◆ is_object()

bool opennn::Json::is_object ( ) const
inlinenoexcept

◆ is_string()

bool opennn::Json::is_string ( ) const
inlinenoexcept

◆ make_array()

static Json opennn::Json::make_array ( )
static

◆ make_object()

static Json opennn::Json::make_object ( )
static

◆ operator[]()

Json & opennn::Json::operator[] ( std::string_view )

◆ parse()

static Json opennn::Json::parse ( std::string_view )
static

◆ push_back()

void opennn::Json::push_back ( Json )

◆ set()

Json & opennn::Json::set ( std::string_view ,
Json  )