mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-16 07:23:43 +02:00
Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ee8b58f82f | ||
![]() |
9132aa94b1 | ||
![]() |
76746b09fc | ||
![]() |
70b795bd45 | ||
![]() |
26842530f2 | ||
![]() |
e3f24286c1 | ||
![]() |
00b8ce81db | ||
![]() |
40810fe326 | ||
![]() |
59167d8627 | ||
![]() |
05c1b8344d | ||
![]() |
e893625e88 | ||
![]() |
e87e41cdb0 | ||
![]() |
9de2c2d84d | ||
![]() |
7956ccd61e | ||
![]() |
9454e687a3 | ||
![]() |
46a925ba4a | ||
![]() |
c407f1407f | ||
![]() |
ec251df6b7 | ||
![]() |
51c0afab22 | ||
![]() |
e39fb0083c | ||
![]() |
ec727e2f6b |
@@ -83,6 +83,14 @@ if ( MSVC )
|
|||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
|
||||||
endif( MSVC )
|
endif( MSVC )
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
# using regular Clang or AppleClang
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
# using GCC
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x")
|
||||||
|
endif()
|
||||||
|
|
||||||
IF(JSONCPP_WITH_WARNING_AS_ERROR)
|
IF(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||||
UseCompilationWarningAsError()
|
UseCompilationWarningAsError()
|
||||||
ENDIF(JSONCPP_WITH_WARNING_AS_ERROR)
|
ENDIF(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#if !defined(JSON_IS_AMALGAMATION)
|
#if !defined(JSON_IS_AMALGAMATION)
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -16,26 +17,26 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#define JSON_ASSERT(condition) \
|
#define JSON_ASSERT(condition) \
|
||||||
assert(condition); // @todo <= change this into an exception throw
|
assert(condition); // @todo <= change this into an exception throw
|
||||||
#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);
|
#define JSON_FAIL_MESSAGE(message) do{std::ostringstream oss; oss << message; throw std::runtime_error(oss.str());}while(0)
|
||||||
|
//#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message)
|
||||||
#else // JSON_USE_EXCEPTION
|
#else // JSON_USE_EXCEPTION
|
||||||
#define JSON_ASSERT(condition) assert(condition);
|
#define JSON_ASSERT(condition) assert(condition);
|
||||||
|
|
||||||
// The call to assert() will show the failure message in debug builds. In
|
// The call to assert() will show the failure message in debug builds. In
|
||||||
// release bugs we write to invalid memory in order to crash hard, so that a
|
// release bugs we abort, for a core-dump or debugger.
|
||||||
// debugger or crash reporter gets the chance to take over. We still call exit()
|
|
||||||
// afterward in order to tell the compiler that this macro doesn't return.
|
|
||||||
#define JSON_FAIL_MESSAGE(message) \
|
#define JSON_FAIL_MESSAGE(message) \
|
||||||
{ \
|
{ \
|
||||||
assert(false&& message); \
|
std::ostringstream oss; oss << message; \
|
||||||
strcpy(reinterpret_cast<char*>(666), message); \
|
assert(false && oss.str().c_str()); \
|
||||||
exit(123); \
|
abort(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define JSON_ASSERT_MESSAGE(condition, message) \
|
#define JSON_ASSERT_MESSAGE(condition, message) \
|
||||||
if (!(condition)) { \
|
if (!(condition)) { \
|
||||||
JSON_FAIL_MESSAGE(message) \
|
JSON_FAIL_MESSAGE(message); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
||||||
|
@@ -392,9 +392,24 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// \return the removed Value, or null.
|
/// \return the removed Value, or null.
|
||||||
/// \pre type() is objectValue or nullValue
|
/// \pre type() is objectValue or nullValue
|
||||||
/// \post type() is unchanged
|
/// \post type() is unchanged
|
||||||
|
/// \deprecated
|
||||||
Value removeMember(const char* key);
|
Value removeMember(const char* key);
|
||||||
/// Same as removeMember(const char*)
|
/// Same as removeMember(const char*)
|
||||||
|
/// \deprecated
|
||||||
Value removeMember(const std::string& key);
|
Value removeMember(const std::string& key);
|
||||||
|
/** \brief Remove the named map member.
|
||||||
|
|
||||||
|
Update 'removed' iff removed.
|
||||||
|
\return true iff removed (no exceptions)
|
||||||
|
*/
|
||||||
|
bool removeMember(const char* key, Value* removed);
|
||||||
|
/** \brief Remove the indexed array element.
|
||||||
|
|
||||||
|
O(n) expensive operations.
|
||||||
|
Update 'removed' iff removed.
|
||||||
|
\return true iff removed (no exceptions)
|
||||||
|
*/
|
||||||
|
bool removeIndex(ArrayIndex i, Value* removed);
|
||||||
|
|
||||||
/// Return true if the object has a member named key.
|
/// Return true if the object has a member named key.
|
||||||
bool isMember(const char* key) const;
|
bool isMember(const char* key) const;
|
||||||
@@ -1082,6 +1097,14 @@ public:
|
|||||||
|
|
||||||
} // namespace Json
|
} // namespace Json
|
||||||
|
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
/// Specialize std::swap() for Json::Value.
|
||||||
|
template<>
|
||||||
|
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
@@ -4,9 +4,9 @@
|
|||||||
#ifndef JSON_VERSION_H_INCLUDED
|
#ifndef JSON_VERSION_H_INCLUDED
|
||||||
# define JSON_VERSION_H_INCLUDED
|
# define JSON_VERSION_H_INCLUDED
|
||||||
|
|
||||||
# define JSONCPP_VERSION_STRING "1.2.0"
|
# define JSONCPP_VERSION_STRING "1.3.0"
|
||||||
# define JSONCPP_VERSION_MAJOR 1
|
# define JSONCPP_VERSION_MAJOR 1
|
||||||
# define JSONCPP_VERSION_MINOR 2
|
# define JSONCPP_VERSION_MINOR 3
|
||||||
# define JSONCPP_VERSION_PATCH 0
|
# define JSONCPP_VERSION_PATCH 0
|
||||||
# define JSONCPP_VERSION_QUALIFIER
|
# define JSONCPP_VERSION_QUALIFIER
|
||||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||||
|
@@ -135,14 +135,9 @@ bool Reader::readValue() {
|
|||||||
bool successful = true;
|
bool successful = true;
|
||||||
|
|
||||||
if (collectComments_ && !commentsBefore_.empty()) {
|
if (collectComments_ && !commentsBefore_.empty()) {
|
||||||
// Remove newline characters at the end of the comments
|
// Remove newline at the end of the comment
|
||||||
size_t lastNonNewline = commentsBefore_.find_last_not_of("\r\n");
|
if (commentsBefore_[commentsBefore_.size() - 1] == '\n')
|
||||||
if (lastNonNewline != std::string::npos) {
|
commentsBefore_.resize(commentsBefore_.size() - 1);
|
||||||
commentsBefore_.erase(lastNonNewline + 1);
|
|
||||||
} else {
|
|
||||||
commentsBefore_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
currentValue().setComment(commentsBefore_, commentBefore);
|
currentValue().setComment(commentsBefore_, commentBefore);
|
||||||
commentsBefore_ = "";
|
commentsBefore_ = "";
|
||||||
}
|
}
|
||||||
@@ -337,14 +332,34 @@ bool Reader::readComment() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string normalizeEOL(Reader::Location begin, Reader::Location end) {
|
||||||
|
std::string normalized;
|
||||||
|
normalized.reserve(end - begin);
|
||||||
|
Reader::Location current = begin;
|
||||||
|
while (current != end) {
|
||||||
|
char c = *current++;
|
||||||
|
if (c == '\r') {
|
||||||
|
if (current != end && *current == '\n')
|
||||||
|
// convert dos EOL
|
||||||
|
++current;
|
||||||
|
// convert Mac EOL
|
||||||
|
normalized += '\n';
|
||||||
|
} else {
|
||||||
|
normalized += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Reader::addComment(Location begin, Location end, CommentPlacement placement) {
|
Reader::addComment(Location begin, Location end, CommentPlacement placement) {
|
||||||
assert(collectComments_);
|
assert(collectComments_);
|
||||||
|
const std::string& normalized = normalizeEOL(begin, end);
|
||||||
if (placement == commentAfterOnSameLine) {
|
if (placement == commentAfterOnSameLine) {
|
||||||
assert(lastValue_ != 0);
|
assert(lastValue_ != 0);
|
||||||
lastValue_->setComment(std::string(begin, end), placement);
|
lastValue_->setComment(normalized, placement);
|
||||||
} else {
|
} else {
|
||||||
commentsBefore_ += std::string(begin, end);
|
commentsBefore_ += normalized;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,8 +375,15 @@ bool Reader::readCStyleComment() {
|
|||||||
bool Reader::readCppStyleComment() {
|
bool Reader::readCppStyleComment() {
|
||||||
while (current_ != end_) {
|
while (current_ != end_) {
|
||||||
Char c = getNextChar();
|
Char c = getNextChar();
|
||||||
if (c == '\r' || c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
|
if (c == '\r') {
|
||||||
|
// Consume DOS EOL. It will be normalized in addComment.
|
||||||
|
if (current_ != end_ && *current_ == '\n')
|
||||||
|
getNextChar();
|
||||||
|
// Break on Moc OS 9 EOL.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -340,7 +340,7 @@ Value::Value(const Value& other)
|
|||||||
case stringValue:
|
case stringValue:
|
||||||
if (other.value_.string_) {
|
if (other.value_.string_) {
|
||||||
value_.string_ = duplicateStringValue(other.value_.string_);
|
value_.string_ = duplicateStringValue(other.value_.string_);
|
||||||
allocated_ = true;
|
allocated_ |= true;
|
||||||
} else {
|
} else {
|
||||||
value_.string_ = 0;
|
value_.string_ = 0;
|
||||||
allocated_ = false;
|
allocated_ = false;
|
||||||
@@ -989,35 +989,74 @@ Value Value::get(const std::string& key, const Value& defaultValue) const {
|
|||||||
return get(key.c_str(), defaultValue);
|
return get(key.c_str(), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Value::removeMember(const char* key, Value* removed) {
|
||||||
|
if (type_ != objectValue) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
CZString actualKey(key, CZString::noDuplication);
|
||||||
|
ObjectValues::iterator it = value_.map_->find(actualKey);
|
||||||
|
if (it == value_.map_->end())
|
||||||
|
return false;
|
||||||
|
*removed = it->second;
|
||||||
|
value_.map_->erase(it);
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
Value* value = value_.map_->find(key);
|
||||||
|
if (value) {
|
||||||
|
*removed = *value;
|
||||||
|
value_.map_.remove(key);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
Value Value::removeMember(const char* key) {
|
Value Value::removeMember(const char* key) {
|
||||||
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
|
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
|
||||||
"in Json::Value::removeMember(): requires objectValue");
|
"in Json::Value::removeMember(): requires objectValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
return null;
|
return null;
|
||||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
CZString actualKey(key, CZString::noDuplication);
|
Value removed; // null
|
||||||
ObjectValues::iterator it = value_.map_->find(actualKey);
|
removeMember(key, &removed);
|
||||||
if (it == value_.map_->end())
|
return removed; // still null if removeMember() did nothing
|
||||||
return null;
|
|
||||||
Value old(it->second);
|
|
||||||
value_.map_->erase(it);
|
|
||||||
return old;
|
|
||||||
#else
|
|
||||||
Value* value = value_.map_->find(key);
|
|
||||||
if (value) {
|
|
||||||
Value old(*value);
|
|
||||||
value_.map_.remove(key);
|
|
||||||
return old;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value Value::removeMember(const std::string& key) {
|
Value Value::removeMember(const std::string& key) {
|
||||||
return removeMember(key.c_str());
|
return removeMember(key.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Value::removeIndex(ArrayIndex index, Value* removed) {
|
||||||
|
if (type_ != arrayValue) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
JSON_FAIL_MESSAGE("removeIndex is not implemented for ValueInternalArray.");
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
CZString key(index);
|
||||||
|
ObjectValues::iterator it = value_.map_->find(key);
|
||||||
|
if (it == value_.map_->end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*removed = it->second;
|
||||||
|
ArrayIndex oldSize = size();
|
||||||
|
// shift left all items left, into the place of the "removed"
|
||||||
|
for (ArrayIndex i = index; i < (oldSize - 1); ++i){
|
||||||
|
CZString key(i);
|
||||||
|
(*value_.map_)[key] = (*this)[i + 1];
|
||||||
|
}
|
||||||
|
// erase the last one ("leftover")
|
||||||
|
CZString keyLast(oldSize - 1);
|
||||||
|
ObjectValues::iterator itLast = value_.map_->find(keyLast);
|
||||||
|
value_.map_->erase(itLast);
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
Value Value::get(const CppTL::ConstString& key,
|
Value Value::get(const CppTL::ConstString& key,
|
||||||
const Value& defaultValue) const {
|
const Value& defaultValue) const {
|
||||||
|
@@ -421,26 +421,27 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) {
|
|||||||
|
|
||||||
document_ += "\n";
|
document_ += "\n";
|
||||||
writeIndent();
|
writeIndent();
|
||||||
std::string normalizedComment = normalizeEOL(root.getComment(commentBefore));
|
const std::string& comment = root.getComment(commentBefore);
|
||||||
std::string::const_iterator iter = normalizedComment.begin();
|
std::string::const_iterator iter = comment.begin();
|
||||||
while (iter != normalizedComment.end()) {
|
while (iter != comment.end()) {
|
||||||
document_ += *iter;
|
document_ += *iter;
|
||||||
if (*iter == '\n' && *(iter + 1) == '/')
|
if (*iter == '\n' &&
|
||||||
|
(iter != comment.end() && *(iter + 1) == '/'))
|
||||||
writeIndent();
|
writeIndent();
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comments are stripped of newlines, so add one here
|
// Comments are stripped of trailing newlines, so add one here
|
||||||
document_ += "\n";
|
document_ += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) {
|
void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) {
|
||||||
if (root.hasComment(commentAfterOnSameLine))
|
if (root.hasComment(commentAfterOnSameLine))
|
||||||
document_ += " " + normalizeEOL(root.getComment(commentAfterOnSameLine));
|
document_ += " " + root.getComment(commentAfterOnSameLine);
|
||||||
|
|
||||||
if (root.hasComment(commentAfter)) {
|
if (root.hasComment(commentAfter)) {
|
||||||
document_ += "\n";
|
document_ += "\n";
|
||||||
document_ += normalizeEOL(root.getComment(commentAfter));
|
document_ += root.getComment(commentAfter);
|
||||||
document_ += "\n";
|
document_ += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,25 +452,6 @@ bool StyledWriter::hasCommentForValue(const Value& value) {
|
|||||||
value.hasComment(commentAfter);
|
value.hasComment(commentAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StyledWriter::normalizeEOL(const std::string& text) {
|
|
||||||
std::string normalized;
|
|
||||||
normalized.reserve(text.length());
|
|
||||||
const char* begin = text.c_str();
|
|
||||||
const char* end = begin + text.length();
|
|
||||||
const char* current = begin;
|
|
||||||
while (current != end) {
|
|
||||||
char c = *current++;
|
|
||||||
if (c == '\r') // mac or dos EOL
|
|
||||||
{
|
|
||||||
if (*current == '\n') // convert dos EOL
|
|
||||||
++current;
|
|
||||||
normalized += '\n';
|
|
||||||
} else // handle unix EOL & other char
|
|
||||||
normalized += c;
|
|
||||||
}
|
|
||||||
return normalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Class StyledStreamWriter
|
// Class StyledStreamWriter
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -646,17 +628,17 @@ void StyledStreamWriter::unindent() {
|
|||||||
void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
|
void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
|
||||||
if (!root.hasComment(commentBefore))
|
if (!root.hasComment(commentBefore))
|
||||||
return;
|
return;
|
||||||
*document_ << normalizeEOL(root.getComment(commentBefore));
|
*document_ << root.getComment(commentBefore);
|
||||||
*document_ << "\n";
|
*document_ << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) {
|
void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) {
|
||||||
if (root.hasComment(commentAfterOnSameLine))
|
if (root.hasComment(commentAfterOnSameLine))
|
||||||
*document_ << " " + normalizeEOL(root.getComment(commentAfterOnSameLine));
|
*document_ << " " + root.getComment(commentAfterOnSameLine);
|
||||||
|
|
||||||
if (root.hasComment(commentAfter)) {
|
if (root.hasComment(commentAfter)) {
|
||||||
*document_ << "\n";
|
*document_ << "\n";
|
||||||
*document_ << normalizeEOL(root.getComment(commentAfter));
|
*document_ << root.getComment(commentAfter);
|
||||||
*document_ << "\n";
|
*document_ << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -667,25 +649,6 @@ bool StyledStreamWriter::hasCommentForValue(const Value& value) {
|
|||||||
value.hasComment(commentAfter);
|
value.hasComment(commentAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StyledStreamWriter::normalizeEOL(const std::string& text) {
|
|
||||||
std::string normalized;
|
|
||||||
normalized.reserve(text.length());
|
|
||||||
const char* begin = text.c_str();
|
|
||||||
const char* end = begin + text.length();
|
|
||||||
const char* current = begin;
|
|
||||||
while (current != end) {
|
|
||||||
char c = *current++;
|
|
||||||
if (c == '\r') // mac or dos EOL
|
|
||||||
{
|
|
||||||
if (*current == '\n') // convert dos EOL
|
|
||||||
++current;
|
|
||||||
normalized += '\n';
|
|
||||||
} else // handle unix EOL & other char
|
|
||||||
normalized += c;
|
|
||||||
}
|
|
||||||
return normalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& sout, const Value& root) {
|
std::ostream& operator<<(std::ostream& sout, const Value& root) {
|
||||||
Json::StyledStreamWriter writer;
|
Json::StyledStreamWriter writer;
|
||||||
writer.write(sout, root);
|
writer.write(sout, root);
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
#define kint64min Json::Value::minInt64
|
#define kint64min Json::Value::minInt64
|
||||||
#define kuint64max Json::Value::maxUInt64
|
#define kuint64max Json::Value::maxUInt64
|
||||||
|
|
||||||
static const double kdint64max = double(kint64max);
|
//static const double kdint64max = double(kint64max);
|
||||||
static const float kfint64max = float(kint64max);
|
//static const float kfint64max = float(kint64max);
|
||||||
static const float kfint32max = float(kint32max);
|
static const float kfint32max = float(kint32max);
|
||||||
static const float kfuint32max = float(kuint32max);
|
static const float kfuint32max = float(kuint32max);
|
||||||
|
|
||||||
@@ -198,6 +198,18 @@ JSONTEST_FIXTURE(ValueTest, objects) {
|
|||||||
|
|
||||||
object1_["some other id"] = "foo";
|
object1_["some other id"] = "foo";
|
||||||
JSONTEST_ASSERT_EQUAL(Json::Value("foo"), object1_["some other id"]);
|
JSONTEST_ASSERT_EQUAL(Json::Value("foo"), object1_["some other id"]);
|
||||||
|
JSONTEST_ASSERT_EQUAL(Json::Value("foo"), object1_["some other id"]);
|
||||||
|
|
||||||
|
// Remove.
|
||||||
|
Json::Value got;
|
||||||
|
bool did;
|
||||||
|
did = object1_.removeMember("some other id", &got);
|
||||||
|
JSONTEST_ASSERT_EQUAL(Json::Value("foo"), got);
|
||||||
|
JSONTEST_ASSERT_EQUAL(true, did);
|
||||||
|
got = Json::Value("bar");
|
||||||
|
did = object1_.removeMember("some other id", &got);
|
||||||
|
JSONTEST_ASSERT_EQUAL(Json::Value("bar"), got);
|
||||||
|
JSONTEST_ASSERT_EQUAL(false, did);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE(ValueTest, arrays) {
|
JSONTEST_FIXTURE(ValueTest, arrays) {
|
||||||
@@ -240,6 +252,10 @@ JSONTEST_FIXTURE(ValueTest, arrays) {
|
|||||||
array1_[2] = Json::Value(17);
|
array1_[2] = Json::Value(17);
|
||||||
JSONTEST_ASSERT_EQUAL(Json::Value(), array1_[1]);
|
JSONTEST_ASSERT_EQUAL(Json::Value(), array1_[1]);
|
||||||
JSONTEST_ASSERT_EQUAL(Json::Value(17), array1_[2]);
|
JSONTEST_ASSERT_EQUAL(Json::Value(17), array1_[2]);
|
||||||
|
Json::Value got;
|
||||||
|
JSONTEST_ASSERT_EQUAL(true, array1_.removeIndex(2, &got));
|
||||||
|
JSONTEST_ASSERT_EQUAL(Json::Value(17), got);
|
||||||
|
JSONTEST_ASSERT_EQUAL(false, array1_.removeIndex(2, &got)); // gone now
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE(ValueTest, null) {
|
JSONTEST_FIXTURE(ValueTest, null) {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
.={}
|
.={}
|
||||||
// Comment for array
|
// Comment for array
|
||||||
.test=[]
|
.test=[]
|
||||||
|
// Comment within array
|
||||||
.test[0]={}
|
.test[0]={}
|
||||||
.test[0].a="aaa"
|
.test[0].a="aaa"
|
||||||
.test[1]={}
|
.test[1]={}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
"test":
|
"test":
|
||||||
// Comment for array
|
// Comment for array
|
||||||
[
|
[
|
||||||
|
// Comment within array
|
||||||
{ "a" : "aaa" }, // Comment for a
|
{ "a" : "aaa" }, // Comment for a
|
||||||
{ "b" : "bbb" }, // Comment for b
|
{ "b" : "bbb" }, // Comment for b
|
||||||
{ "c" : "ccc" } // Comment for c
|
{ "c" : "ccc" } // Comment for c
|
||||||
|
Reference in New Issue
Block a user