Protective Stop
Loading...
Searching...
No Matches
jsonlite::Value Struct Reference

A parsed JSON value: null, bool, number, string, array or object. More...

#include <json_lite.hpp>

Public Types

enum  Type {
  NUL , BOOL , NUM , STR ,
  ARR , OBJ
}
 JSON type held by a Value.

Public Member Functions

bool is_obj () const
 True when type is OBJ.
bool is_arr () const
 True when type is ARR.
const Value * find (const std::string &key) const
 Returns the member named key, or nullptr if absent or not an object.
double as_num (double dflt=0.0) const
 Number value, or dflt unless type is NUM.
bool as_bool (bool dflt=false) const
 Bool value, a NUM compared against zero, or dflt for other types.
std::string as_str (const std::string &dflt="") const
 String value, or dflt unless type is STR.
double num_at (const std::string &k, double dflt=0.0) const
 as_num() of member k, or dflt if the member is absent.
bool bool_at (const std::string &k, bool dflt=false) const
 as_bool() of member k, or dflt if the member is absent.
std::string str_at (const std::string &k, const std::string &dflt="") const
 as_str() of member k, or dflt if the member is absent.

Public Attributes

Type type {NUL}
 Active type; selects which of the members below is meaningful.
bool b {false}
 Value when type is BOOL.
double num {0.0}
 Value when type is NUM.
std::string str
 Value when type is STR.
std::vector< Value > arr
 Elements when type is ARR.
std::map< std::string, Value > obj
 Members when type is OBJ.

Detailed Description

A parsed JSON value: null, bool, number, string, array or object.

Accessors return the supplied default when the value has a different type.


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