Lightweight json to write any STL compositions.
More...
#include <json.h>
|
| | JSONWriter (std::ostream *os) |
| | Constructor.
|
| |
| void | WriteNoEscape (const std::string &s) |
| | Write a string that do not contain escape characters.
|
| |
| void | WriteString (const std::string &s) |
| | Write a string that can contain escape characters.
|
| |
| template<typename ValueType > |
| void | WriteNumber (const ValueType &v) |
| | Write a string that can contain escape characters.
|
| |
| void | BeginArray (bool multi_line=true) |
| | Start beginning of array.
|
| |
|
void | EndArray () |
| | Finish writing an array.
|
| |
| void | BeginObject (bool multi_line=true) |
| | Start beginning of array.
|
| |
|
void | EndObject () |
| | Finish writing object.
|
| |
| template<typename ValueType > |
| void | WriteObjectKeyValue (const std::string &key, const ValueType &value) |
| | Write key value pair in the object.
|
| |
|
void | WriteArraySeperator () |
| | Write seperator of array, before writing next element. User can proceed to call writer->Write to write next item.
|
| |
| template<typename ValueType > |
| void | WriteArrayItem (const ValueType &value) |
| | Write value into array.
|
| |
| template<typename ValueType > |
| void | Write (const ValueType &value) |
| | Write value to json.
|
| |
Lightweight json to write any STL compositions.
◆ JSONWriter()
| dmlc::JSONWriter::JSONWriter |
( |
std::ostream * |
os | ) |
|
|
inlineexplicit |
◆ BeginArray()
| void dmlc::JSONWriter::BeginArray |
( |
bool |
multi_line = true | ) |
|
|
inline |
Start beginning of array.
- Parameters
-
| multi_line | whether to start an multi_line array. writer->BeginArray();
for (auto& v : vdata) {
writer->WriteArrayItem(v);
}
writer->EndArray();
|
◆ BeginObject()
| void dmlc::JSONWriter::BeginObject |
( |
bool |
multi_line = true | ) |
|
|
inline |
Start beginning of array.
- Parameters
-
| multi_line | whether to start an multi_line array. writer->BeginObject();
for (auto& kv : vmap) {
writer->WriteObjectKeyValue(kv.first, kv.second);
}
writer->EndObject();
|
◆ Write()
template<typename ValueType >
| void dmlc::JSONWriter::Write |
( |
const ValueType & |
value | ) |
|
|
inline |
Write value to json.
- Parameters
-
| value | any STL or json readable that can be written. |
- Template Parameters
-
| ValueType | the data type to be write. |
◆ WriteArrayItem()
template<typename ValueType >
| void dmlc::JSONWriter::WriteArrayItem |
( |
const ValueType & |
value | ) |
|
|
inline |
Write value into array.
- Parameters
-
| value | The value of to be written. |
- Template Parameters
-
| ValueType | The value type to be written. |
◆ WriteNoEscape()
| void dmlc::JSONWriter::WriteNoEscape |
( |
const std::string & |
s | ) |
|
|
inline |
Write a string that do not contain escape characters.
- Parameters
-
| s | the string to be written. |
◆ WriteNumber()
template<typename ValueType >
| void dmlc::JSONWriter::WriteNumber |
( |
const ValueType & |
v | ) |
|
|
inline |
Write a string that can contain escape characters.
- Parameters
-
| v | the value to be written. |
- Template Parameters
-
| ValueType | The value type to be written. |
◆ WriteObjectKeyValue()
template<typename ValueType >
| void dmlc::JSONWriter::WriteObjectKeyValue |
( |
const std::string & |
key, |
|
|
const ValueType & |
value |
|
) |
| |
|
inline |
Write key value pair in the object.
- Parameters
-
| key | the key of the object. |
| value | the value of to be written. |
- Template Parameters
-
| ValueType | The value type to be written. |
◆ WriteString()
| void dmlc::JSONWriter::WriteString |
( |
const std::string & |
s | ) |
|
|
inline |
Write a string that can contain escape characters.
- Parameters
-
| s | the string to be written. |
The documentation for this class was generated from the following file:
- External/xgboost/dmlc-core/include/dmlc/json.h