xgboost

Public Member Functions | Static Public Member Functions | Friends | List of all members
xgboost::Json Class Reference

Data structure representing JSON format. More...

`#include <json.h>`

Collaboration diagram for xgboost::Json:

## Public Member Functions
| Json ()
| Json (JsonNumber number)
Json & | operator= (JsonNumber number)
| Json (JsonInteger integer)
Json & | operator= (JsonInteger integer)
| Json (JsonArray &&list)
Json & | operator= (JsonArray &&array)
template<typename T , Value::ValueKind kind>
| Json (JsonTypedArray< T, kind > &&list)
template<typename T , Value::ValueKind kind>
Json & | operator= (JsonTypedArray< T, kind > &&array)
| Json (JsonObject &&object)
Json & | operator= (JsonObject &&object)
| Json (JsonString &&str)
Json & | operator= (JsonString &&str)
| Json (JsonBoolean boolean)
Json & | operator= (JsonBoolean boolean)
| Json (JsonNull null)
Json & | operator= (JsonNull null)
| Json (Json const &other)=default
Json & | operator= (Json const &other)=default
| Json (Json &&other) noexcept
Json & | operator= (Json &&other) noexcept
Json & | operator[] (std::string const &key) const
| Index Json object with a std::string, used for Json Object. More...
Json & | operator[] (int ind) const
| Index Json object with int, used for Json Array. More...
Value const & | GetValue () const &
| Return the reference to stored Json value. More...
Value const & | GetValue () &&
Value & | GetValue () &
bool | operator== (Json const &rhs) const
IntrusivePtr< Value > const & | Ptr () const

## Static Public Member Functions
static Json | Load (StringView str, std::ios::openmode mode=std::ios::in)
| Decode the JSON object. Optional parameter mode for choosing between text and binary (ubjson) input. More...
static Json | Load (JsonReader *reader)
| Pass your own JsonReader. More...
static void | Dump (Json json, std::string *out, std::ios::openmode mode=std::ios::out)
| Encode the JSON object. Optional parameter mode for choosing between text and binary (ubjson) output. More...
static void | Dump (Json json, std::vector< char > *out, std::ios::openmode mode=std::ios::out)
static void | Dump (Json json, JsonWriter *writer)
| Use your own JsonWriter. More...

## Friends
std::ostream & | operator<< (std::ostream &os, Json const &j)

## Detailed Description

Data structure representing JSON format.

Limitation: UTF-8 is not properly supported. Code points above ASCII are invalid.

Examples:

// Create a JSON object.
Json object { Object() };
// Assign key "key" with a JSON string "Value";
object["key"] = String("Value");
// Assign key "arr" with a empty JSON Array;
object["arr"] = Array();

## Constructor & Destructor Documentation

## ◆ Json() [1/11]

xgboost::Json::Json | ( |  | ) |
| inline

## ◆ Json() [2/11]

xgboost::Json::Json | ( | JsonNumber | number | ) |
| inline explicit

## ◆ Json() [3/11]

xgboost::Json::Json | ( | JsonInteger | integer | ) |
| inline explicit

## ◆ Json() [4/11]

xgboost::Json::Json | ( | JsonArray && | list | ) |
| inline explicit

## ◆ Json() [5/11]

template<typename T , Value::ValueKind kind>

xgboost::Json::Json | ( | JsonTypedArray< T, kind > && | list | ) |
| inline explicit

## ◆ Json() [6/11]

xgboost::Json::Json | ( | JsonObject && | object | ) |
| inline explicit

## ◆ Json() [7/11]

xgboost::Json::Json | ( | JsonString && | str | ) |
| inline explicit

## ◆ Json() [8/11]

xgboost::Json::Json | ( | JsonBoolean | boolean | ) |
| inline explicit

## ◆ Json() [9/11]

xgboost::Json::Json | ( | JsonNull | null | ) |
| inline explicit

## ◆ Json() [10/11]

xgboost::Json::Json | ( | Json const & | other | ) |
| default

## ◆ Json() [11/11]

xgboost::Json::Json | ( | Json && | other | ) |
| inline noexcept

## Member Function Documentation

## ◆ Dump() [1/3]

static void xgboost::Json::Dump | ( | Json | json,
|  | JsonWriter * | writer
| ) |  |
| static

Use your own JsonWriter.

## ◆ Dump() [2/3]

static void xgboost::Json::Dump | ( | Json | json,
|  | std::string * | out,
|  | std::ios::openmode | mode = `std::ios::out`
| ) |  |
| static

Encode the JSON object. Optional parameter mode for choosing between text and binary (ubjson) output.

## ◆ Dump() [3/3]

static void xgboost::Json::Dump | ( | Json | json,
|  | std::vector< char > * | out,
|  | std::ios::openmode | mode = `std::ios::out`
| ) |  |
| static

## ◆ GetValue() [1/3]

Value& xgboost::Json::GetValue | ( |  | ) | &
| inline

## ◆ GetValue() [2/3]

Value const& xgboost::Json::GetValue | ( |  | ) | &&
| inline

## ◆ GetValue() [3/3]

Value const& xgboost::Json::GetValue | ( |  | ) | const &
| inline

Return the reference to stored Json value.

## ◆ Load() [1/2]

static Json xgboost::Json::Load | ( | JsonReader * | reader | ) |
| static

Pass your own JsonReader.

## ◆ Load() [2/2]

static Json xgboost::Json::Load | ( | StringView | str,
|  | std::ios::openmode | mode = `std::ios::in`
| ) |  |
| static

Decode the JSON object. Optional parameter mode for choosing between text and binary (ubjson) input.

## ◆ operator=() [1/10]

Json& xgboost::Json::operator= | ( | Json && | other | ) |
| inline noexcept

## ◆ operator=() [2/10]

Json& xgboost::Json::operator= | ( | Json const & | other | ) |
| default

## ◆ operator=() [3/10]

Json& xgboost::Json::operator= | ( | JsonArray && | array | ) |
| inline

## ◆ operator=() [4/10]

Json& xgboost::Json::operator= | ( | JsonBoolean | boolean | ) |
| inline

## ◆ operator=() [5/10]

Json& xgboost::Json::operator= | ( | JsonInteger | integer | ) |
| inline

## ◆ operator=() [6/10]

Json& xgboost::Json::operator= | ( | JsonNull | null | ) |
| inline

## ◆ operator=() [7/10]

Json& xgboost::Json::operator= | ( | JsonNumber | number | ) |
| inline

## ◆ operator=() [8/10]

Json& xgboost::Json::operator= | ( | JsonObject && | object | ) |
| inline

## ◆ operator=() [9/10]

Json& xgboost::Json::operator= | ( | JsonString && | str | ) |
| inline

## ◆ operator=() [10/10]

template<typename T , Value::ValueKind kind>

Json& xgboost::Json::operator= | ( | JsonTypedArray< T, kind > && | array | ) |
| inline

## ◆ operator==()

bool xgboost::Json::operator== | ( | Json const & | rhs | ) | const
| inline

## ◆ operator[]() [1/2]

Json& xgboost::Json::operator[] | ( | int | ind | ) | const
| inline

Index Json object with int, used for Json Array.

## ◆ operator[]() [2/2]

Json& xgboost::Json::operator[] | ( | std::string const & | key | ) | const
| inline

Index Json object with a std::string, used for Json Object.

## ◆ Ptr()

IntrusivePtr<Value> const& xgboost::Json::Ptr | ( |  | ) | const
| inline

## Friends And Related Function Documentation

## ◆ operator<<

std::ostream& operator<< | ( | std::ostream & | os,
|  | Json const & | j
| ) |  |
| friend

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

- /home/runner/work/xgboost/xgboost/include/xgboost/json.h

xgboost::Array
JsonArray Array
Definition: json.h:589
xgboost::String
JsonString String
Definition: json.h:593
xgboost::Object
JsonObject Object
Definition: json.h:588
xgboost::Json::Json
Json()
Definition: json.h:370