54 for (
const auto&
c :
s)
74 if (
c >= 0x00 &&
c <= 0x1f)
90 const auto space = json_extra_space(
s);
93 return std::string(
s);
101 for (
const auto&
c :
s)
170 if (
c >= 0x00 &&
c <= 0x1f)
200 std::vector<std::string> col_names = subset;
201 if (subset.empty()) {
202 col_names = this->data ? this->
get_col_names() : std::vector<std::string>({});
205 const size_t _n_cols = col_names.size();
206 std::string ret =
"{";
208 for (
size_t i = 0; i < _n_cols; i++) {
209 auto& col = col_names[i];
213 ret +=
'"' + internals::json_escape_string(col) +
"\":";
219 ret +=
'"' + internals::json_escape_string(field.get<
csv::string_view>()) +
'"';
238 std::vector<std::string> col_names = subset;
240 col_names = this->data ? this->
get_col_names() : std::vector<std::string>({});
242 const size_t _n_cols = col_names.size();
243 std::string ret =
"[";
245 for (
size_t i = 0; i < _n_cols; i++) {
252 ret +=
'"' + internals::json_escape_string(field.get<
csv::string_view>()) +
'"';
std::string to_json(const std::vector< std::string > &subset={}) const
Convert a CSV row to a JSON object, i.e.
std::string to_json_array(const std::vector< std::string > &subset={}) const
Convert a CSV row to a JSON array, i.e.
std::vector< std::string > get_col_names() const
Retrieve this row's associated column names.
CSVField operator[](size_t n) const
Return a CSVField object corrsponding to the nth value in the row.
#define CSV_INLINE
Helper macro which should be #defined as "inline" in the single header version.
Defines the data type used for storing information about a CSV row.
CSV_CONST CONSTEXPR_17 OutArray arrayToDefault(T &&value)
Helper constexpr function to initialize an array with all the elements set to value.
The all encompassing namespace.
nonstd::string_view string_view
The string_view class used by this library.