Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/SQLiteCppUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -57,7 +58,7 @@ Json::Value SQLiteUtils::execute(SQLite::Statement& query)
}
case SQLITE_NULL:
{
row[column.getName()] = Json::nullValue;
row[column.getName()] = nullptr;
break;
}
case SQLITE_TEXT:
Expand All @@ -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.
Expand Down
7 changes: 3 additions & 4 deletions src/SQLiteCppUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,22 @@

#pragma once


#include "ofMain.h"
#include "SQLiteCpp.h"
#include <json/json.h>


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);


};
Expand Down