200 explicit operator bool()
const {
return is_valid(); }
304 double Or(
double fallback)
const;
314 int64_t
Or(
long long fallback)
const;
319 int64_t
Or(
int fallback)
const;
324 int64_t
Or(
unsigned fallback)
const;
329 int64_t
Or(
long fallback)
const;
334 int64_t
Or(
unsigned long fallback)
const;
339 int64_t
Or(
unsigned long long fallback)
const;
344 double Or(
float fallback)
const;
353 bool Or(
bool fallback)
const;
415 explicit JSON(detail::JSONData* adopted_node);
417 detail::JSONData* node_ =
nullptr;
584 explicit operator bool()
const {
return is_valid(); }
669 Ref(detail::JSONData* parent,
const String& key);
670 Ref(detail::JSONData* parent,
size_t index);
672 detail::JSONData* parent_;
718 bool operator==(
const iterator& other)
const {
return index_ == other.index_; }
719 bool operator!=(
const iterator& other)
const {
return index_ != other.index_; }
723 iterator(
const JSONObject*
object,
size_t index) : object_(object), index_(index) {}
764 detail::JSONData* node_;
806 bool operator==(
const iterator& other)
const {
return index_ == other.index_; }
807 bool operator!=(
const iterator& other)
const {
return index_ != other.index_; }
811 iterator(
const JSONArray* array,
size_t index) : array_(array), index_(index) {}
866 void Push(
unsigned long value);
876 void Push(
unsigned long long value);
905 explicit JSONArray(detail::JSONData* node);
907 JSON ElementAt(
size_t index)
const;
909 detail::JSONData* node_;
#define UExport
Definition Exports.h:22
Assignable reference to a value inside a mutable JSON document.
Definition JSON.h:463
int64_t Or(unsigned long long fallback) const
Same as Or(long long).
Ref & operator=(const Ref &other)
Write the value other refers to into the referenced place.
double Or(float fallback) const
Same as Or(double).
Ref & operator=(unsigned long long value)
Write a number into the referenced place.
int64_t Or(long long fallback) const
Read the referenced value as a number, truncated toward zero to an integer.
Ref & operator=(long long value)
Write a number into the referenced place.
String Or(const char *fallback) const
Same as Or(const String&).
Ref(const Ref &other)
Copy constructor (copies the reference itself, not the referenced value).
Ref & operator=(const String &value)
Write a string into the referenced place.
Ref operator[](const String &key)
Chain to an object member, creating the referenced place as an object if it is missing or holds null.
String Or(const String &fallback) const
Read the referenced value as a string.
Ref & operator=(const char *value)
Write a string into the referenced place.
bool is_null() const
Whether or not the referenced place holds a JSON null.
Ref operator[](size_t index)
Chain to an array element.
Ref & operator=(const JSON &value)
Write value into the referenced place, sharing its document.
friend class JSON
Definition JSON.h:668
int64_t Or(unsigned fallback) const
Same as Or(long long).
int64_t Or(int fallback) const
Same as Or(long long).
bool is_valid() const
Whether or not the referenced place holds a value.
double Or(double fallback) const
Read the referenced value as a number (the same as JSON::Or()).
bool Or(bool fallback) const
Read the referenced value as a boolean.
Ref & operator=(int value)
Write a number into the referenced place.
Ref & operator=(bool value)
Write a boolean into the referenced place.
Ref & operator=(long value)
Write a number into the referenced place.
Ref & operator=(unsigned value)
Write a number into the referenced place.
Ref & operator=(double value)
Write a number into the referenced place.
Ref & operator=(decltype(nullptr))
Write a JSON null into the referenced place.
int64_t Or(long fallback) const
Same as Or(long long).
Ref & operator=(unsigned long value)
Write a number into the referenced place.
int64_t Or(unsigned long fallback) const
Same as Or(long long).
Input iterator over an array's elements (yields JSON by value).
Definition JSON.h:799
bool operator!=(const iterator &other) const
Definition JSON.h:807
bool operator==(const iterator &other) const
Definition JSON.h:806
friend class JSONArray
Definition JSON.h:810
iterator & operator++()
Definition JSON.h:802
JSON operator*() const
Definition JSON.h:801
A view of a JSON array.
Definition JSON.h:794
void Push(long long value)
Append a number.
void Push(unsigned value)
Append a number.
iterator begin() const
Get an iterator to the first element.
Definition JSON.h:896
size_t size() const
Get the number of elements (0 for an empty view).
friend class JSON
Definition JSON.h:904
iterator end() const
Get an iterator past the last element.
Definition JSON.h:901
void Push(unsigned long long value)
Append a number.
void Push(double value)
Append a number.
void Push(const char *value)
Append a string.
void Push(int value)
Append a number.
void Push(unsigned long value)
Append a number.
void Push(const String &value)
Append a string.
JSONArray(const JSONArray &other)
Copy constructor.
void Push(long value)
Append a number.
void Push(bool value)
Append a boolean.
void Push(decltype(nullptr))
Append a JSON null.
void Push(const JSON &value)
Append value, sharing its document.
int64_t Or(unsigned long long fallback) const
Same as Or(long long).
static JSON Parse(const String &text)
Parse JSON text.
double Or(float fallback) const
Same as Or(double).
int64_t Or(long long fallback) const
Read this value as a number, truncated toward zero to an integer.
JSON & operator=(JSON &&other)
Move assignment operator.
String Or(const char *fallback) const
Same as Or(const String&).
JSON operator[](size_t index) const
Read an array element.
JSON(const JSON &other)
Create a copy of another JSON.
friend class JSONObject
Definition JSON.h:413
unsigned error_line() const
Get the 1-based line number of the parse error (0 unless this is a failed Parse() result).
JSON()
Create an empty, invalid JSON value.
String Stringify(unsigned indent=0) const
Serialize this value to JSON text.
bool is_string() const
Whether or not this value is a string.
String error_message() const
Get the parse error description ("" unless this is a failed Parse() result).
Ref operator[](const String &key)
Get an assignable reference to an object member.
String Or(const String &fallback) const
Read this value as a string.
bool is_null() const
Whether or not this value is null.
Ref operator[](size_t index)
Get an assignable reference to an array element.
JSON & operator=(const JSON &other)
Assignment operator.
int64_t Or(unsigned fallback) const
Same as Or(long long).
bool is_bool() const
Whether or not this value is a boolean.
int64_t Or(int fallback) const
Same as Or(long long).
JSONArray AsArray() const
Get a typed view of this value as an array (for iteration, size(), and Push()).
JSON(JSON &&other)
Move constructor.
bool is_number() const
Whether or not this value is a number.
bool is_valid() const
Whether or not this JSON holds a value.
JSON operator[](const String &key) const
Read an object member.
friend class JSONArray
Definition JSON.h:414
double Or(double fallback) const
Read this value as a number.
bool Or(bool fallback) const
Read this value as a boolean.
JSONObject AsObject() const
Get a typed view of this value as an object (for iteration, Has(), and size()).
JSON Clone() const
Deep-copy this value into an independent document.
bool is_array() const
Whether or not this value is an array.
int64_t Or(long fallback) const
Same as Or(long long).
static JSON Object()
Create a new empty object value.
bool is_object() const
Whether or not this value is an object.
static JSON Array()
Create a new empty array value.
int64_t Or(unsigned long fallback) const
Same as Or(long long).
Input iterator over an object's members (yields JSON::Member by value).
Definition JSON.h:711
bool operator!=(const iterator &other) const
Definition JSON.h:719
friend class JSONObject
Definition JSON.h:722
bool operator==(const iterator &other) const
Definition JSON.h:718
JSON::Member operator*() const
Definition JSON.h:713
iterator & operator++()
Definition JSON.h:714
Typed view of a JSON object for checking keys and stepping through its members.
Definition JSON.h:706
iterator begin() const
Get an iterator to the first member (insertion order).
Definition JSON.h:751
size_t size() const
Get the number of members (0 for an empty view).
friend class JSON
Definition JSON.h:759
iterator end() const
Get an iterator past the last member.
Definition JSON.h:756
JSONObject(const JSONObject &other)
Copy constructor.
bool Has(const String &key) const
Whether or not the object has a member with the given key.
Unicode string container with conversions for UTF-8, UTF-16, and UTF-32.
Definition String.h:31
Root namespace for every public Ultralight type, function, and enumeration.
One object member, as visited by JSONObject iteration.
Definition JSON.h:423
JSON value
The member's value (shared with the document).
Definition JSON.h:425
String key
The member name.
Definition JSON.h:424