mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 04:17:55 +01:00
feat(Data): Add JSONRowFormatter #3602
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "Poco/Data/Statement.h"
|
||||
#include "Poco/Data/RecordSet.h"
|
||||
#include "Poco/Data/RowFormatter.h"
|
||||
#include "Poco/Data/JSONRowFormatter.h"
|
||||
#include "Poco/Data/SQLite/Connector.h"
|
||||
#include <iostream>
|
||||
|
||||
@@ -27,6 +28,7 @@ using Poco::Data::Session;
|
||||
using Poco::Data::Statement;
|
||||
using Poco::Data::RecordSet;
|
||||
using Poco::Data::RowFormatter;
|
||||
using Poco::Data::JSONRowFormatter;
|
||||
|
||||
|
||||
class HTMLTableFormatter : public RowFormatter
|
||||
@@ -117,5 +119,11 @@ int main(int argc, char** argv)
|
||||
std::cout << std::endl << "Simple formatting:" << std::endl << std::endl;
|
||||
std::cout << RecordSet(session, "SELECT * FROM Simpsons");
|
||||
|
||||
// JSON formatting example (uses the JSONRowFormatter provided by framework)
|
||||
std::cout << std::endl << "JSON formatting:" << std::endl << std::endl;
|
||||
JSONRowFormatter jsonRowFormatter;
|
||||
jsonRowFormatter.setJSONMode((RowFormatter::Mode)(JSONRowFormatter::JSON_FMT_MODE_ROW_COUNT | JSONRowFormatter::JSON_FMT_MODE_COLUMN_NAMES));
|
||||
std::cout << RecordSet(session, "SELECT * FROM Simpsons", jsonRowFormatter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user