6#if !defined(JSON_IS_AMALGAMATION)
21#if defined(_MSC_VER) && _MSC_VER < 1900
23static int msvc_pre1900_c99_vsnprintf(
char* outBuf,
size_t size,
24 const char* format, va_list ap) {
27 count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
29 count = _vscprintf(format, ap);
33int JSON_API msvc_pre1900_c99_snprintf(
char* outBuf,
size_t size,
34 const char* format, ...) {
37 const int count = msvc_pre1900_c99_vsnprintf(outBuf, size, format, ap);
45#pragma warning(disable : 4702)
48#define JSON_ASSERT_UNREACHABLE assert(false)
52static std::unique_ptr<T>
cloneUnique(
const std::unique_ptr<T>& p) {
55 r = std::unique_ptr<T>(
new T(*p));
64#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
66#define ALIGNAS(byte_alignment)
71 static Value const nullStatic;
85#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
86template <
typename T,
typename U>
87static inline bool InRange(
double d, T min, U max) {
90 return d >=
static_cast<double>(min) && d <=
static_cast<double>(max) &&
91 !(
static_cast<U
>(d) == min && d !=
static_cast<double>(min));
94static inline double integerToDouble(
Json::UInt64 value) {
95 return static_cast<double>(
Int64(value / 2)) * 2.0 +
96 static_cast<double>(
Int64(value & 1));
99template <
typename T>
static inline double integerToDouble(T value) {
100 return static_cast<double>(value);
103template <
typename T,
typename U>
104static inline bool InRange(
double d, T min, U max) {
105 return d >= integerToDouble(min) && d <= integerToDouble(max) &&
106 !(
static_cast<U
>(d) == min && d != integerToDouble(min));
123 auto newString =
static_cast<char*
>(malloc(length + 1));
124 if (newString ==
nullptr) {
126 "Failed to allocate string value buffer");
128 memcpy(newString, value, length);
129 newString[length] = 0;
136 unsigned int length) {
140 sizeof(
unsigned) - 1U,
141 "in Json::Value::duplicateAndPrefixStringValue(): "
142 "length too big for prefixing");
143 size_t actualLength =
sizeof(length) + length + 1;
144 auto newString =
static_cast<char*
>(malloc(actualLength));
145 if (newString ==
nullptr) {
147 "Failed to allocate string value buffer");
149 *
reinterpret_cast<unsigned*
>(newString) = length;
150 memcpy(newString +
sizeof(
unsigned), value, length);
151 newString[actualLength - 1U] =
156 unsigned* length,
char const** value) {
158 *length =
static_cast<unsigned>(strlen(prefixed));
161 *length = *
reinterpret_cast<unsigned const*
>(prefixed);
162 *value = prefixed +
sizeof(unsigned);
168#if JSONCPP_USE_SECURE_MEMORY
171 char const* valueDecoded;
173 size_t const size =
sizeof(unsigned) + length + 1U;
174 memset(value, 0, size);
179 size_t size = (length == 0) ? strlen(value) : length;
180 memset(value, 0, size);
210 return "stringValue";
212 return "booleanValue";
216 return "objectValue";
223#if !defined(JSON_IS_AMALGAMATION)
230#if JSON_USE_EXCEPTION
244 std::cerr << msg << std::endl;
248 std::cerr << msg << std::endl;
267Value::CZString::CZString(
ArrayIndex index) : cstr_(nullptr), index_(index) {}
269Value::CZString::CZString(
char const* str,
unsigned length,
270 DuplicationPolicy allocate)
273 storage_.policy_ = allocate & 0x3;
274 storage_.length_ = length & 0x3FFFFFFF;
277Value::CZString::CZString(
const CZString& other) {
278 cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ !=
nullptr
283 static_cast<unsigned>(
285 ? (static_cast<DuplicationPolicy>(other.storage_.policy_) ==
289 : static_cast<DuplicationPolicy>(other.storage_.policy_)) &
291 storage_.length_ = other.storage_.length_;
293 index_ = other.index_;
297Value::CZString::CZString(CZString&& other) noexcept : cstr_(other.cstr_) {
299 storage_.policy_ = other.storage_.policy_;
300 storage_.length_ = other.storage_.length_;
302 index_ = other.index_;
304 other.cstr_ =
nullptr;
307Value::CZString::~CZString() {
308 if (cstr_ && storage_.policy_ == duplicate) {
310 storage_.length_ + 1U);
317void Value::CZString::swap(CZString& other) {
318 std::swap(cstr_, other.cstr_);
319 std::swap(index_, other.index_);
322Value::CZString& Value::CZString::operator=(
const CZString& other) {
324 index_ = other.index_;
328Value::CZString& Value::CZString::operator=(CZString&& other)
noexcept {
329 if (cstr_ && storage_.policy_ == duplicate) {
336 storage_.policy_ = other.storage_.policy_;
337 storage_.length_ = other.storage_.length_;
339 index_ = other.index_;
341 other.cstr_ =
nullptr;
345bool Value::CZString::operator<(
const CZString& other)
const {
347 return index_ < other.index_;
350 unsigned this_len = this->storage_.length_;
351 unsigned other_len = other.storage_.length_;
352 unsigned min_len = std::min<unsigned>(this_len, other_len);
354 int comp = memcmp(this->cstr_, other.cstr_, min_len);
359 return (this_len < other_len);
362bool Value::CZString::operator==(
const CZString& other)
const {
364 return index_ == other.index_;
367 unsigned this_len = this->storage_.length_;
368 unsigned other_len = other.storage_.length_;
369 if (this_len != other_len)
372 int comp = memcmp(this->cstr_, other.cstr_, this_len);
376ArrayIndex Value::CZString::index()
const {
return index_; }
379const char* Value::CZString::data()
const {
return cstr_; }
380unsigned Value::CZString::length()
const {
return storage_.length_; }
381bool Value::CZString::isStaticString()
const {
382 return storage_.policy_ == noDuplication;
399 static char const emptyString[] =
"";
413 value_.string_ =
const_cast<char*
>(
static_cast<char const*
>(emptyString));
417 value_.map_ =
new ObjectValues();
420 value_.bool_ =
false;
434 value_.uint_ = value;
436#if defined(JSON_HAS_INT64)
443 value_.uint_ = value;
449 value_.real_ = value;
455 "Null Value Passed to Value Constructor");
457 value,
static_cast<unsigned>(strlen(value)));
469 value.data(),
static_cast<unsigned>(value.length()));
474 value_.string_ =
const_cast<char*
>(value.
c_str());
479 value_.bool_ = value;
498 Value(other).swap(*
this);
508 std::swap(bits_, other.bits_);
509 std::swap(value_, other.value_);
519 std::swap(comments_, other.comments_);
520 std::swap(start_, other.start_);
521 std::swap(limit_, other.limit_);
530 return static_cast<ValueType>(bits_.value_type_);
542 int typeDelta =
type() - other.
type();
544 return typeDelta < 0;
549 return value_.int_ < other.value_.int_;
551 return value_.uint_ < other.value_.uint_;
553 return value_.real_ < other.value_.real_;
555 return value_.bool_ < other.value_.bool_;
557 if ((value_.string_ ==
nullptr) || (other.value_.string_ ==
nullptr)) {
558 return other.value_.string_ !=
nullptr;
562 char const* this_str;
563 char const* other_str;
568 unsigned min_len = std::min<unsigned>(this_len, other_len);
570 int comp = memcmp(this_str, other_str, min_len);
575 return (this_len < other_len);
579 auto thisSize = value_.map_->size();
580 auto otherSize = other.value_.map_->size();
581 if (thisSize != otherSize)
582 return thisSize < otherSize;
583 return (*value_.map_) < (*other.value_.map_);
604 return value_.int_ == other.value_.int_;
606 return value_.uint_ == other.value_.uint_;
608 return value_.real_ == other.value_.real_;
610 return value_.bool_ == other.value_.bool_;
612 if ((value_.string_ ==
nullptr) || (other.value_.string_ ==
nullptr)) {
613 return (value_.string_ == other.value_.string_);
617 char const* this_str;
618 char const* other_str;
623 if (this_len != other_len)
626 int comp = memcmp(this_str, other_str, this_len);
631 return value_.map_->size() == other.value_.map_->size() &&
632 (*value_.map_) == (*other.value_.map_);
643 "in Json::Value::asCString(): requires stringValue");
644 if (value_.string_ ==
nullptr)
647 char const* this_str;
653#if JSONCPP_USE_SECURE_MEMORY
654unsigned Value::getCStringLength()
const {
656 "in Json::Value::asCString(): requires stringValue");
657 if (value_.string_ == 0)
660 char const* this_str;
670 if (value_.string_ ==
nullptr)
684 if (value_.string_ ==
nullptr)
687 char const* this_str;
690 return String(this_str, this_len);
693 return value_.bool_ ?
"true" :
"false";
709 return Int(value_.int_);
712 return Int(value_.uint_);
715 "double out of Int range");
716 return Int(value_.real_);
720 return value_.bool_ ? 1 : 0;
731 return UInt(value_.int_);
734 return UInt(value_.uint_);
737 "double out of UInt range");
738 return UInt(value_.real_);
742 return value_.bool_ ? 1 : 0;
749#if defined(JSON_HAS_INT64)
754 return Int64(value_.int_);
757 return Int64(value_.uint_);
763 "Double value is minInt64, precise value cannot be determined");
765 "double out of Int64 range");
766 return Int64(value_.real_);
770 return value_.bool_ ? 1 : 0;
781 return UInt64(value_.int_);
783 return UInt64(value_.uint_);
786 "double out of UInt64 range");
787 return UInt64(value_.real_);
791 return value_.bool_ ? 1 : 0;
800#if defined(JSON_NO_INT64)
808#if defined(JSON_NO_INT64)
818 return static_cast<double>(value_.int_);
820#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
821 return static_cast<double>(value_.uint_);
823 return integerToDouble(value_.uint_);
830 return value_.bool_ ? 1.0 : 0.0;
840 return static_cast<float>(value_.int_);
842#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
843 return static_cast<float>(value_.uint_);
846 return static_cast<float>(integerToDouble(value_.uint_));
849 return static_cast<float>(value_.real_);
853 return value_.bool_ ? 1.0F : 0.0F;
867 return value_.int_ != 0;
869 return value_.uint_ != 0;
872 const auto value_classification = std::fpclassify(value_.real_);
873 return value_classification != FP_ZERO && value_classification != FP_NAN;
925 if (!value_.map_->empty()) {
926 ObjectValues::const_iterator itLast = value_.map_->end();
928 return (*itLast).first.index() + 1;
944Value::operator bool()
const {
return !
isNull(); }
949 "in Json::Value::clear(): requires complex value");
955 value_.map_->clear();
965 "in Json::Value::resize(): requires arrayValue, but found "
972 else if (newSize > oldSize)
973 for (
ArrayIndex i = oldSize; i < newSize; ++i)
976 for (
ArrayIndex index = newSize; index < oldSize; ++index) {
977 value_.map_->erase(index);
986 "in Json::Value::operator[](ArrayIndex): requires arrayValue");
990 auto it = value_.map_->lower_bound(key);
991 if (it != value_.map_->end() && (*it).first == key)
1000 value_.map_->insert(value_.map_->end(),
1003 ObjectValues::value_type defaultValue(key,
nullSingleton());
1004 it = value_.map_->insert(it, defaultValue);
1005 return (*it).second;
1011 "in Json::Value::operator[](int index): index cannot be negative");
1018 "in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
1021 CZString key(index);
1022 ObjectValues::const_iterator it = value_.map_->find(key);
1023 if (it == value_.map_->end())
1025 return (*it).second;
1031 "in Json::Value::operator[](int index) const: index cannot be negative");
1035void Value::initBasic(
ValueType type,
bool allocated) {
1037 setIsAllocated(allocated);
1038 comments_ = Comments{};
1043void Value::dupPayload(
const Value& other) {
1044 setType(other.type());
1045 setIsAllocated(
false);
1052 value_ = other.value_;
1055 if (other.value_.string_ && other.isAllocated()) {
1061 setIsAllocated(
true);
1063 value_.string_ = other.value_.string_;
1068 value_.map_ =
new ObjectValues(*other.value_.map_);
1075void Value::releasePayload() {
1096void Value::dupMeta(
const Value& other) {
1097 comments_ = other.comments_;
1098 start_ = other.start_;
1099 limit_ = other.limit_;
1105Value& Value::resolveReference(
const char* key) {
1107 type() == nullValue || type() == objectValue,
1108 "in Json::Value::resolveReference(): requires objectValue, but found "
1110 if (type() == nullValue)
1111 *
this = Value(objectValue);
1112 CZString actualKey(key,
static_cast<unsigned>(strlen(key)),
1113 CZString::noDuplication);
1114 auto it = value_.map_->lower_bound(actualKey);
1115 if (it != value_.map_->end() && (*it).first == actualKey)
1116 return (*it).second;
1118 ObjectValues::value_type defaultValue(actualKey, nullSingleton());
1119 it = value_.map_->insert(it, defaultValue);
1120 Value& value = (*it).second;
1125Value& Value::resolveReference(
char const* key,
char const* end) {
1127 "in Json::Value::resolveReference(key, end): requires "
1128 "objectValue, but found "
1130 if (type() == nullValue)
1131 *
this = Value(objectValue);
1132 CZString actualKey(key,
static_cast<unsigned>(end - key),
1133 CZString::duplicateOnCopy);
1134 auto it = value_.map_->lower_bound(actualKey);
1135 if (it != value_.map_->end() && (*it).first == actualKey)
1136 return (*it).second;
1138 ObjectValues::value_type defaultValue(actualKey, nullSingleton());
1139 it = value_.map_->insert(it, defaultValue);
1140 Value& value = (*it).second;
1145 const Value* value = &((*this)[index]);
1153 "in Json::Value::find(begin, end): requires "
1154 "objectValue or nullValue");
1157 CZString actualKey(
begin,
static_cast<unsigned>(
end -
begin),
1158 CZString::noDuplication);
1159 ObjectValues::const_iterator it = value_.map_->find(actualKey);
1160 if (it == value_.map_->end())
1162 return &(*it).second;
1165 return find(key.data(), key.data() + key.length());
1207 "in Json::Value::demand(begin, end): requires "
1208 "objectValue or nullValue");
1209 return &resolveReference(
begin,
end);
1212 Value const* found =
find(key, key + strlen(key));
1225 return resolveReference(key, key + strlen(key));
1229 return resolveReference(key.data(), key.data() + key.length());
1233 return resolveReference(key.
c_str());
1240 "in Json::Value::append: requires arrayValue, but found "
1245 return this->value_.map_->emplace(
size(), std::move(value)).first->second;
1254 "in Json::Value::insert: requires arrayValue");
1256 if (index > length) {
1259 for (
ArrayIndex i = length; i > index; i--) {
1260 (*this)[i] = std::move((*
this)[i - 1]);
1262 (*this)[index] = std::move(newValue);
1267 Value const& defaultValue)
const {
1269 return !found ? defaultValue : *found;
1272 return get(key, key + strlen(key), defaultValue);
1275 return get(key.data(), key.data() + key.length(), defaultValue);
1282 CZString actualKey(
begin,
static_cast<unsigned>(
end -
begin),
1283 CZString::noDuplication);
1284 auto it = value_.map_->find(actualKey);
1285 if (it == value_.map_->end())
1288 *removed = std::move(it->second);
1289 value_.map_->erase(it);
1296 return removeMember(key.data(), key.data() + key.length(), removed);
1302 "in Json::Value::removeMember(): requires objectValue, but found "
1307 CZString actualKey(key,
unsigned(strlen(key)), CZString::noDuplication);
1308 value_.map_->erase(actualKey);
1316 CZString key(index);
1317 auto it = value_.map_->find(key);
1318 if (it == value_.map_->end()) {
1322 *removed = std::move(it->second);
1325 for (
ArrayIndex i = index; i < (oldSize - 1); ++i) {
1327 (*value_.map_)[keey] = (*
this)[i + 1];
1330 CZString keyLast(oldSize - 1);
1331 auto itLast = value_.map_->find(keyLast);
1332 value_.map_->erase(itLast);
1338 return nullptr != value;
1341 return isMember(key, key + strlen(key));
1344 return isMember(key.data(), key.data() + key.length());
1350 "in Json::Value::getMemberNames(), value must be objectValue");
1354 members.reserve(value_.map_->size());
1355 ObjectValues::const_iterator it = value_.map_->begin();
1356 ObjectValues::const_iterator itEnd = value_.map_->end();
1357 for (; it != itEnd; ++it) {
1358 members.push_back(
String((*it).first.data(), (*it).first.length()));
1364 double integral_part;
1365 return modf(d, &integral_part) == 0.0;
1375#if defined(JSON_HAS_INT64)
1383 return value_.real_ >=
minInt && value_.real_ <=
maxInt &&
1394#if defined(JSON_HAS_INT64)
1397 return value_.int_ >= 0;
1400#if defined(JSON_HAS_INT64)
1401 return value_.uint_ <=
maxUInt;
1406 return value_.real_ >= 0 && value_.real_ <=
maxUInt &&
1415#if defined(JSON_HAS_INT64)
1429 return value_.real_ > double(
minInt64) && value_.real_ < double(
maxInt64) &&
1439#if defined(JSON_HAS_INT64)
1442 return value_.int_ >= 0;
1464#if defined(JSON_HAS_INT64)
1472 return value_.real_ > double(
minInt64) &&
1496Value::Comments::Comments(
const Comments& that)
1499Value::Comments::Comments(Comments&& that) noexcept
1500 : ptr_{std::move(that.ptr_)} {}
1502Value::Comments& Value::Comments::operator=(
const Comments& that) {
1507Value::Comments& Value::Comments::operator=(Comments&& that)
noexcept {
1508 ptr_ = std::move(that.ptr_);
1513 return ptr_ && !(*ptr_)[slot].empty();
1519 return (*ptr_)[slot];
1526 ptr_ = std::unique_ptr<Array>(
new Array());
1527 (*ptr_)[slot] = std::move(comment);
1531 if (!comment.empty() && (comment.back() ==
'\n')) {
1536 comment.empty() || comment[0] ==
'/',
1537 "in Json::Value::setComment(): Comments must start with /");
1538 comments_.set(placement, std::move(comment));
1542 return comments_.has(placement);
1546 return comments_.get(placement);
1598 return iterator(value_.map_->begin());
1611 return iterator(value_.map_->end());
1625 : index_(index), kind_(kindIndex) {}
1647void Path::makePath(
const String& path,
const InArgs& in) {
1648 const char* current = path.c_str();
1649 const char* end = current + path.length();
1650 auto itInArg = in.begin();
1651 while (current != end) {
1652 if (*current ==
'[') {
1654 if (*current ==
'%')
1655 addPathInArg(path, in, itInArg, PathArgument::kindIndex);
1658 for (; current != end && *current >=
'0' && *current <=
'9'; ++current)
1659 index = index * 10 +
ArrayIndex(*current -
'0');
1660 args_.push_back(index);
1662 if (current == end || *++current !=
']')
1663 invalidPath(path,
int(current - path.c_str()));
1664 }
else if (*current ==
'%') {
1665 addPathInArg(path, in, itInArg, PathArgument::kindKey);
1667 }
else if (*current ==
'.' || *current ==
']') {
1670 const char* beginName = current;
1671 while (current != end && !strchr(
"[.", *current))
1673 args_.push_back(
String(beginName, current));
1678void Path::addPathInArg(
const String& ,
const InArgs& in,
1679 InArgs::const_iterator& itInArg,
1680 PathArgument::Kind kind) {
1681 if (itInArg == in.end()) {
1683 }
else if ((*itInArg)->kind_ != kind) {
1686 args_.push_back(**itInArg++);
1690void Path::invalidPath(
const String& ,
int ) {
1695 const Value* node = &root;
1696 for (
const auto& arg : args_) {
1697 if (arg.kind_ == PathArgument::kindIndex) {
1702 node = &((*node)[arg.index_]);
1703 }
else if (arg.kind_ == PathArgument::kindKey) {
1708 node = &((*node)[arg.key_]);
1720 const Value* node = &root;
1721 for (
const auto& arg : args_) {
1722 if (arg.kind_ == PathArgument::kindIndex) {
1724 return defaultValue;
1725 node = &((*node)[arg.index_]);
1726 }
else if (arg.kind_ == PathArgument::kindKey) {
1728 return defaultValue;
1729 node = &((*node)[arg.key_]);
1731 return defaultValue;
1738 Value* node = &root;
1739 for (
const auto& arg : args_) {
1740 if (arg.kind_ == PathArgument::kindIndex) {
1744 node = &((*node)[arg.index_]);
1745 }
else if (arg.kind_ == PathArgument::kindKey) {
1749 node = &((*node)[arg.key_]);
#define JSON_ASSERT(condition)
It should not be possible for a maliciously designed file to cause an abort() or seg-fault,...
#define JSON_FAIL_MESSAGE(message)
#define JSON_ASSERT_MESSAGE(condition, message)
char const * what() const noexcept override
~Exception() noexcept override
LogicError(String const &msg)
Experimental and untested: represents an element of the "path" to access a node.
Path(const String &path, const PathArgument &a1=PathArgument(), const PathArgument &a2=PathArgument(), const PathArgument &a3=PathArgument(), const PathArgument &a4=PathArgument(), const PathArgument &a5=PathArgument())
Value & make(Value &root) const
Creates the "path" to access the specified node and returns a reference on the node.
const Value & resolve(const Value &root) const
RuntimeError(String const &msg)
Lightweight wrapper to tag static string.
const char * c_str() const
Build a StreamWriter implementation.
const_iterator begin() const
Value get(ArrayIndex index, const Value &defaultValue) const
If the array contains at least index+1 elements, returns the element value, otherwise returns default...
bool empty() const
Return true if empty array, empty object, or null; otherwise, false.
Json::ArrayIndex ArrayIndex
ArrayIndex size() const
Number of values in array or object.
const char * asCString() const
Embedded zeroes could cause you trouble!
bool operator==(const Value &other) const
static constexpr Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
void copy(const Value &other)
copy everything.
static const Value & null
Value const * findDouble(const String &key) const
void setComment(const char *comment, CommentPlacement placement)
ptrdiff_t getOffsetLimit() const
bool getString(char const **begin, char const **end) const
Get raw char* of string-value.
Value const * findString(const String &key) const
static constexpr double maxUInt64AsDouble
std::vector< String > Members
const_iterator end() const
bool operator<=(const Value &other) const
String getComment(CommentPlacement placement) const
Include delimiters and embedded newlines.
bool operator>(const Value &other) const
String toStyledString() const
void clear()
Remove all object members and array elements.
String asString() const
Embedded zeroes are possible.
void swapPayload(Value &other)
Swap values but leave comments and source offsets in place.
void setOffsetLimit(ptrdiff_t limit)
bool removeIndex(ArrayIndex index, Value *removed)
Remove the indexed array element.
Value const * findArray(const String &key) const
bool hasComment(CommentPlacement placement) const
Json::LargestInt LargestInt
Json::LargestUInt LargestUInt
ValueConstIterator const_iterator
void removeMember(std::string_view key)
Remove and return the named member.
bool isMember(std::string_view key) const
Return true if the object has a member named key.
Members getMemberNames() const
Return a list of the member names.
void resize(ArrayIndex newSize)
Resize the array to newSize elements.
Value & operator[](ArrayIndex index)
Value & append(const Value &value)
Append value to array at the end.
Value const * findBool(const String &key) const
bool operator!=(const Value &other) const
Value const * findValue(const String &key) const
Calls find and only returns a valid pointer if the type is found.
Value const * findInt64(const String &key) const
void setOffsetStart(ptrdiff_t start)
ValueMembersView members()
Value const * findNull(const String &key) const
Value const * findUInt(const String &key) const
Value * demand(char const *begin, char const *end)
Most general and efficient version of object-mutators.
void swap(Value &other)
Swap everything.
bool operator<(const Value &other) const
Compare payload only, not comments etc.
Value const * findInt(const String &key) const
static const Value & nullRef
LargestInt asLargestInt() const
void copyPayload(const Value &other)
copy values but leave comments and source offsets in place.
Value const * findIntegral(const String &key) const
static constexpr Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Value const * findNumeric(const String &key) const
bool isValidIndex(ArrayIndex index) const
Return true if index < size().
Value const * findUInt64(const String &key) const
LargestUInt asLargestUInt() const
Value const * findObject(const String &key) const
Value(ValueType type=nullValue)
Create a default Value of the given type.
static constexpr UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
Value & operator=(const Value &other)
static constexpr Int minInt
Minimum signed int value that can be stored in a Json::Value.
bool insert(ArrayIndex index, const Value &newValue)
Insert value in array at specific index.
static constexpr Int64 minInt64
Minimum signed 64 bits int value that can be stored in a Json::Value.
int compare(const Value &other) const
bool isConvertibleTo(ValueType other) const
static Value const & nullSingleton()
ptrdiff_t getOffsetStart() const
Value const * find(char const *begin, char const *end) const
Most general and efficient version of isMember()const, get()const, and operator[]const.
bool operator>=(const Value &other) const
static constexpr UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
#define JSON_ASSERT_UNREACHABLE
JSON (JavaScript Object Notation).
void throwLogicError(String const &msg)
used internally
static char * duplicateStringValue(const char *value, size_t length)
Duplicates the specified string value.
static bool IsIntegral(double d)
static const char * valueTypeToString(ValueType type)
static void releaseStringValue(char *value, unsigned)
static void releasePrefixedStringValue(char *value)
Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
String writeString(StreamWriter::Factory const &factory, Value const &root)
Write into stringstream, then return string, for convenience.
@ commentBefore
a comment placed on the line before a value
@ numberOfCommentPlacement
root value)
String valueToString(Int value)
ValueType
Type of the value held by a Value object.
@ stringValue
UTF-8 string value.
@ arrayValue
array value (ordered list)
@ intValue
signed integer value
@ objectValue
object value (collection of name/value pairs).
@ uintValue
unsigned integer value
void throwRuntimeError(String const &msg)
used internally
static void decodePrefixedString(bool isPrefixed, char const *prefixed, unsigned *length, char const **value)
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
static std::unique_ptr< T > cloneUnique(const std::unique_ptr< T > &p)
static char * duplicateAndPrefixStringValue(const char *value, unsigned int length)
static bool InRange(double d, T min, U max)
#define JSONCPP_VERSION_STRING