From d1c947bda16fe6779f2e49691c2cea5f187735e8 Mon Sep 17 00:00:00 2001 From: smallfly Date: Mon, 22 Feb 2016 17:19:42 -0500 Subject: [PATCH 1/2] Now using ofJson included in OF's core. --- src/SQLiteCppUtils.cpp | 11 ++++++----- src/SQLiteCppUtils.h | 7 +++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/SQLiteCppUtils.cpp b/src/SQLiteCppUtils.cpp index 8142e45..6eaa7e0 100644 --- a/src/SQLiteCppUtils.cpp +++ b/src/SQLiteCppUtils.cpp @@ -31,13 +31,14 @@ namespace SQLite { -Json::Value SQLiteUtils::execute(SQLite::Statement& query) +ofJson SQLiteUtils::execute(SQLite::Statement& query) { - Json::Value columns; + + ofJson columns; while (query.executeStep()) { - Json::Value row; + ofJson row; for (int i = 0; i < query.getColumnCount(); ++i) { @@ -83,8 +84,8 @@ Json::Value SQLiteUtils::execute(SQLite::Statement& query) } } } - - columns.append(row); + + columns.push_back(row); } // Reset the query to use it again. diff --git a/src/SQLiteCppUtils.h b/src/SQLiteCppUtils.h index b999698..4419b13 100644 --- a/src/SQLiteCppUtils.h +++ b/src/SQLiteCppUtils.h @@ -25,10 +25,8 @@ #pragma once - +#include "ofMain.h" #include "SQLiteCpp.h" -#include - namespace SQLite { @@ -36,12 +34,13 @@ namespace SQLite { class SQLiteUtils { public: + /// \brief Export SQLite results as JSON. /// /// Encodes BLOBs using BASE64. /// /// Throws exceptions. - static Json::Value execute(SQLite::Statement& query); + static ofJson execute(SQLite::Statement& query); }; From dcc8c95299fcd228d02bb4fda4ea4bfa05b13609 Mon Sep 17 00:00:00 2001 From: smallfly Date: Mon, 22 Feb 2016 21:47:03 -0500 Subject: [PATCH 2/2] Replaced Json::nullValue (from JsonCpp) by nullptr used with 'JSON for Modern C++'. --- src/SQLiteCppUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SQLiteCppUtils.cpp b/src/SQLiteCppUtils.cpp index 6eaa7e0..4789068 100644 --- a/src/SQLiteCppUtils.cpp +++ b/src/SQLiteCppUtils.cpp @@ -58,7 +58,7 @@ ofJson SQLiteUtils::execute(SQLite::Statement& query) } case SQLITE_NULL: { - row[column.getName()] = Json::nullValue; + row[column.getName()] = nullptr; break; } case SQLITE_TEXT: