51             std::size_t result = 0;
 
   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);
 
   97             size_t result_size = s.size() + space;
 
   98             std::string result(result_size, 
'\\');
 
  101             for (
const auto& c : s)
 
  108                     result[pos + 1] = 
'"';
 
  126                     result[pos + 1] = 
'b';
 
  135                     result[pos + 1] = 
'f';
 
  144                     result[pos + 1] = 
'n';
 
  153                     result[pos + 1] = 
'r';
 
  162                     result[pos + 1] = 
't';
 
  170                     if (c >= 0x00 && c <= 0x1f)
 
  173                         snprintf(&result[pos + 1], result_size - pos - 1, 
"u%04x", 
int(c));
 
  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.
The all encompassing namespace.
nonstd::string_view string_view
The string_view class used by this library.