ClickHouse/src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.3 KiB
C++
Raw Normal View History

2019-02-19 18:41:18 +00:00
#pragma once
#include <Core/Block.h>
#include <IO/WriteBuffer.h>
#include <Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h>
2019-02-19 18:41:18 +00:00
#include <Formats/FormatSettings.h>
namespace DB
{
/** The stream for outputting data in JSON format, by object per line.
*/
class JSONEachRowRowOutputFormat : public RowOutputFormatWithUTF8ValidationAdaptor
2019-02-19 18:41:18 +00:00
{
public:
2020-09-02 04:05:02 +00:00
JSONEachRowRowOutputFormat(
WriteBuffer & out_,
const Block & header_,
const RowOutputFormatParams & params_,
const FormatSettings & settings_);
2019-02-19 18:41:18 +00:00
String getName() const override { return "JSONEachRowRowOutputFormat"; }
/// Content-Type to set when sending HTTP response.
String getContentType() const override
2021-12-03 09:48:28 +00:00
{
return settings.json.array_of_rows ? "application/json; charset=UTF-8" : "application/x-ndjson; charset=UTF-8" ;
}
2021-11-02 13:40:41 +00:00
protected:
2021-03-09 14:46:52 +00:00
void writeField(const IColumn & column, const ISerialization & serialization, size_t row_num) override;
2019-02-19 18:41:18 +00:00
void writeFieldDelimiter() override;
void writeRowStartDelimiter() override;
void writeRowEndDelimiter() override;
void writeRowBetweenDelimiter() override;
void writePrefix() override;
void writeSuffix() override;
2019-02-19 18:41:18 +00:00
size_t field_number = 0;
private:
2019-02-19 18:41:18 +00:00
Names fields;
FormatSettings settings;
};
}