libzypp 17.31.23
zypp::json::Value Class Reference

JSON representation of datatypes via toJSON. More...

#include <base/Json.h>

Inheritance diagram for zypp::json::Value:

Public Member Functions

 Value ()
 Default ctor (null)
 
 Value (const Value &rhs)
 Copy ctor.
 
template<class T >
 Value (const T &val_r)
 Ctor creating a JSON representation of T via toJSON(T)
 
const std::string & asJSON () const
 JSON representation.
 
const std::string & asString () const
 String representation.
 
std::ostream & dumpOn (std::ostream &str) const
 Stream output.
 

Private Attributes

std::string _data
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const Value &obj)
 Stream output.
 

Detailed Description

JSON representation of datatypes via toJSON.

namespace mynamspace
{
struct Mydata
{...};
std::string toJSON( const Mydata & )
{ return json::Array{ "answer", 42 }.asJSON(); }
}
mynamspace::Mydata data;
json::Object bigone {
{ "mydata", data },
{ "panic", false },
{ "nested", json::Object{ {"one",1}, {"two",2}, {"three",3} } }
};
cout << bigone << endl;
std::string toJSON(void)
Definition: Json.h:136
JSON array.
Definition: Json.h:257
std::string asJSON() const
JSON representation.
Definition: Json.h:279
See also
http://www.json.org/

Definition at line 202 of file Json.h.

Constructor & Destructor Documentation

◆ Value() [1/3]

zypp::json::Value::Value ( )
inline

Default ctor (null)

Definition at line 205 of file Json.h.

◆ Value() [2/3]

zypp::json::Value::Value ( const Value rhs)
inline

Copy ctor.

Definition at line 208 of file Json.h.

◆ Value() [3/3]

template<class T >
zypp::json::Value::Value ( const T &  val_r)
inline

Ctor creating a JSON representation of T via toJSON(T)

Definition at line 212 of file Json.h.

Member Function Documentation

◆ asJSON()

const std::string & zypp::json::Value::asJSON ( ) const
inline

JSON representation.

Definition at line 215 of file Json.h.

◆ asString()

const std::string & zypp::json::Value::asString ( ) const
inline

String representation.

Definition at line 219 of file Json.h.

◆ dumpOn()

std::ostream & zypp::json::Value::dumpOn ( std::ostream &  str) const
inline

Stream output.

Definition at line 223 of file Json.h.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  str,
const Value obj 
)
related

Stream output.

Definition at line 231 of file Json.h.

Member Data Documentation

◆ _data

std::string zypp::json::Value::_data
private

Definition at line 227 of file Json.h.


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