string_t::object_type decode_escaped_string()

in src/codec/string.cpp [140:157]


string_t::object_type decode_escaped_string(decode_context &context, const char *begin) {
  std::string unescaped(begin, context.position - 1);
  decode_escape(context, unescaped);

  while (json_likely(context.remaining())) {
    const auto begin_simple = context.position;
    detail::skip_any_simple_characters(context);
    unescaped.append(begin_simple, context.position);

    switch (detail::next(context, "Unterminated string")) {
      case '"': return unescaped;
      case '\\': decode_escape(context, unescaped); break;
      default: json_unreachable();
    }
  }

  detail::fail(context, "Unterminated string");
}