mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 15:16:47 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5b3e8a8984 | ||
![]() |
4a6b5a33ed | ||
![]() |
37ea604585 | ||
![]() |
fd288c3750 | ||
![]() |
27c5762141 | ||
![]() |
bc67af2210 | ||
![]() |
83f10358f8 | ||
![]() |
115f9b91cf | ||
![]() |
c56d73b9a2 |
@@ -59,7 +59,7 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating header...")
|
print("Amalgating header...")
|
||||||
header = AmalgamationFile(source_top_dir)
|
header = AmalgamationFile(source_top_dir)
|
||||||
header.add_text("/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).")
|
header.add_text("/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).")
|
||||||
header.add_text('/// It is intended to be used with #include "%s"' % header_include_path)
|
header.add_text("/// It is intented to be used with #include <%s>" % header_include_path)
|
||||||
header.add_file("LICENSE", wrap_in_comment=True)
|
header.add_file("LICENSE", wrap_in_comment=True)
|
||||||
header.add_text("#ifndef JSON_AMALGATED_H_INCLUDED")
|
header.add_text("#ifndef JSON_AMALGATED_H_INCLUDED")
|
||||||
header.add_text("# define JSON_AMALGATED_H_INCLUDED")
|
header.add_text("# define JSON_AMALGATED_H_INCLUDED")
|
||||||
@@ -85,7 +85,7 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating forward header...")
|
print("Amalgating forward header...")
|
||||||
header = AmalgamationFile(source_top_dir)
|
header = AmalgamationFile(source_top_dir)
|
||||||
header.add_text("/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).")
|
header.add_text("/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).")
|
||||||
header.add_text('/// It is intended to be used with #include "%s"' % forward_header_include_path)
|
header.add_text("/// It is intented to be used with #include <%s>" % forward_header_include_path)
|
||||||
header.add_text("/// This header provides forward declaration for all JsonCpp types.")
|
header.add_text("/// This header provides forward declaration for all JsonCpp types.")
|
||||||
header.add_file("LICENSE", wrap_in_comment=True)
|
header.add_file("LICENSE", wrap_in_comment=True)
|
||||||
header.add_text("#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED")
|
header.add_text("#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED")
|
||||||
@@ -105,15 +105,10 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating source...")
|
print("Amalgating source...")
|
||||||
source = AmalgamationFile(source_top_dir)
|
source = AmalgamationFile(source_top_dir)
|
||||||
source.add_text("/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).")
|
source.add_text("/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).")
|
||||||
source.add_text('/// It is intended to be used with #include "%s"' % header_include_path)
|
source.add_text("/// It is intented to be used with #include <%s>" % header_include_path)
|
||||||
source.add_file("LICENSE", wrap_in_comment=True)
|
source.add_file("LICENSE", wrap_in_comment=True)
|
||||||
source.add_text("")
|
source.add_text("")
|
||||||
source.add_text('#include "%s"' % header_include_path)
|
source.add_text("#include <%s>" % header_include_path)
|
||||||
source.add_text("""
|
|
||||||
#ifndef JSON_IS_AMALGAMATION
|
|
||||||
#error "Compile with -I PATH_TO_JSON_DIRECTORY"
|
|
||||||
#endif
|
|
||||||
""")
|
|
||||||
source.add_text("")
|
source.add_text("")
|
||||||
lib_json = "src/lib_json"
|
lib_json = "src/lib_json"
|
||||||
source.add_file(os.path.join(lib_json, "json_tool.h"))
|
source.add_file(os.path.join(lib_json, "json_tool.h"))
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
#if JSON_USE_EXCEPTION
|
#if JSON_USE_EXCEPTION
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#define JSON_ASSERT(condition) \
|
#define JSON_ASSERT(condition) \
|
||||||
if (!(condition)) {throw std::runtime_error( "assert json failed" );} // @todo <= add detail about condition in exception
|
assert(condition); // @todo <= change this into an exception throw
|
||||||
#define JSON_FAIL_MESSAGE(message) do{std::ostringstream oss; oss << message; throw std::runtime_error(oss.str());}while(0)
|
#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)
|
//#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message)
|
||||||
#else // JSON_USE_EXCEPTION
|
#else // JSON_USE_EXCEPTION
|
||||||
|
@@ -4,10 +4,10 @@
|
|||||||
#ifndef JSON_VERSION_H_INCLUDED
|
#ifndef JSON_VERSION_H_INCLUDED
|
||||||
# define JSON_VERSION_H_INCLUDED
|
# define JSON_VERSION_H_INCLUDED
|
||||||
|
|
||||||
# define JSONCPP_VERSION_STRING "0.8.4"
|
# define JSONCPP_VERSION_STRING "0.8.2"
|
||||||
# define JSONCPP_VERSION_MAJOR 0
|
# define JSONCPP_VERSION_MAJOR 0
|
||||||
# define JSONCPP_VERSION_MINOR 8
|
# define JSONCPP_VERSION_MINOR 8
|
||||||
# define JSONCPP_VERSION_PATCH 4
|
# define JSONCPP_VERSION_PATCH 2
|
||||||
# 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))
|
||||||
|
|
||||||
|
@@ -1060,8 +1060,6 @@ bool OurReader::readValue() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tokenArraySeparator:
|
case tokenArraySeparator:
|
||||||
case tokenObjectEnd:
|
|
||||||
case tokenArrayEnd:
|
|
||||||
if (features_.allowDroppedNullPlaceholders_) {
|
if (features_.allowDroppedNullPlaceholders_) {
|
||||||
// "Un-read" the current token and mark the current value as a null
|
// "Un-read" the current token and mark the current value as a null
|
||||||
// token.
|
// token.
|
||||||
@@ -1069,7 +1067,8 @@ bool OurReader::readValue() {
|
|||||||
Value v;
|
Value v;
|
||||||
currentValue().swapPayload(v);
|
currentValue().swapPayload(v);
|
||||||
break;
|
break;
|
||||||
} // else, fall through ...
|
}
|
||||||
|
// Else, fall through...
|
||||||
default:
|
default:
|
||||||
return addError("Syntax error: value, object or array expected.", token);
|
return addError("Syntax error: value, object or array expected.", token);
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ namespace Json {
|
|||||||
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
|
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
|
||||||
#else
|
#else
|
||||||
// This exists for binary compatibility only. Use nullRef.
|
// This exists for binary compatibility only. Use nullRef.
|
||||||
const Value Value::null;
|
static const Value null;
|
||||||
#define ALIGNAS(byte_alignment)
|
#define ALIGNAS(byte_alignment)
|
||||||
#endif
|
#endif
|
||||||
static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
|
static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
|
||||||
|
@@ -282,8 +282,6 @@ JSONTEST_FIXTURE(ValueTest, null) {
|
|||||||
JSONTEST_ASSERT_EQUAL(0.0, null_.asDouble());
|
JSONTEST_ASSERT_EQUAL(0.0, null_.asDouble());
|
||||||
JSONTEST_ASSERT_EQUAL(0.0, null_.asFloat());
|
JSONTEST_ASSERT_EQUAL(0.0, null_.asFloat());
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", null_.asString());
|
JSONTEST_ASSERT_STRING_EQUAL("", null_.asString());
|
||||||
|
|
||||||
JSONTEST_ASSERT_EQUAL(Json::Value::null, null_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE(ValueTest, strings) {
|
JSONTEST_FIXTURE(ValueTest, strings) {
|
||||||
@@ -1794,158 +1792,6 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterBool) {
|
|||||||
delete reader;
|
delete reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CharReaderAllowDropNullTest : JsonTest::TestCase {};
|
|
||||||
|
|
||||||
JSONTEST_FIXTURE(CharReaderAllowDropNullTest, issue178) {
|
|
||||||
Json::CharReaderBuilder b;
|
|
||||||
b.settings_["allowDroppedNullPlaceholders"] = true;
|
|
||||||
Json::Value root;
|
|
||||||
std::string errs;
|
|
||||||
Json::CharReader* reader(b.newCharReader());
|
|
||||||
{
|
|
||||||
char const doc[] = "{\"a\":,\"b\":true}";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(2u, root.size());
|
|
||||||
JSONTEST_ASSERT_EQUAL(Json::nullValue, root.get("a", true));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "{\"a\":}";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(1u, root.size());
|
|
||||||
JSONTEST_ASSERT_EQUAL(Json::nullValue, root.get("a", true));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT(errs == "");
|
|
||||||
JSONTEST_ASSERT_EQUAL(0u, root.size());
|
|
||||||
JSONTEST_ASSERT_EQUAL(Json::arrayValue, root);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[null]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT(errs == "");
|
|
||||||
JSONTEST_ASSERT_EQUAL(1u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[,]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(2u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[,,,]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(4u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[null,]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(2u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[,null]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT(errs == "");
|
|
||||||
JSONTEST_ASSERT_EQUAL(2u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[,,]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(3u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[null,,]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(3u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[,null,]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(3u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[,,null]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT(errs == "");
|
|
||||||
JSONTEST_ASSERT_EQUAL(3u, root.size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[[],,,]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(4u, root.size());
|
|
||||||
JSONTEST_ASSERT_EQUAL(Json::arrayValue, root[0u]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[,[],,]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
|
||||||
JSONTEST_ASSERT_EQUAL(4u, root.size());
|
|
||||||
JSONTEST_ASSERT_EQUAL(Json::arrayValue, root[1u]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char const doc[] = "[,,,[]]";
|
|
||||||
bool ok = reader->parse(
|
|
||||||
doc, doc + std::strlen(doc),
|
|
||||||
&root, &errs);
|
|
||||||
JSONTEST_ASSERT(ok);
|
|
||||||
JSONTEST_ASSERT(errs == "");
|
|
||||||
JSONTEST_ASSERT_EQUAL(4u, root.size());
|
|
||||||
JSONTEST_ASSERT_EQUAL(Json::arrayValue, root[3u]);
|
|
||||||
}
|
|
||||||
delete reader;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct IteratorTest : JsonTest::TestCase {};
|
struct IteratorTest : JsonTest::TestCase {};
|
||||||
|
|
||||||
JSONTEST_FIXTURE(IteratorTest, distance) {
|
JSONTEST_FIXTURE(IteratorTest, distance) {
|
||||||
@@ -2007,8 +1853,6 @@ int main(int argc, const char* argv[]) {
|
|||||||
JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterArray);
|
JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterArray);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterBool);
|
JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterBool);
|
||||||
|
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, CharReaderAllowDropNullTest, issue178);
|
|
||||||
|
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, distance);
|
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, distance);
|
||||||
|
|
||||||
return runner.runCommandLine(argc, argv);
|
return runner.runCommandLine(argc, argv);
|
||||||
|
Reference in New Issue
Block a user