MCPcopy Create free account
hub / github.com/ByConity/ByConity / readJSONStringInto

Function readJSONStringInto

src/IO/ReadHelpers.cpp:831–867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

829
830template <typename Vector, typename ReturnType>
831ReturnType readJSONStringInto(Vector & s, ReadBuffer & buf)
832{
833 static constexpr bool throw_exception = std::is_same_v<ReturnType, void>;
834
835 auto error = [](const char * message [[maybe_unused]], int code [[maybe_unused]])
836 {
837 if constexpr (throw_exception)
838 throw ParsingException(message, code);
839 return ReturnType(false);
840 };
841
842 if (buf.eof() || *buf.position() != '"')
843 return error("Cannot parse JSON string: expected opening quote", ErrorCodes::CANNOT_PARSE_QUOTED_STRING);
844 ++buf.position();
845
846 while (!buf.eof())
847 {
848 char * next_pos = find_first_symbols<'\\', '"'>(buf.position(), buf.buffer().end());
849
850 appendToStringOrVector(s, buf, next_pos);
851 buf.position() = next_pos;
852
853 if (!buf.hasPendingData())
854 continue;
855
856 if (*buf.position() == '"')
857 {
858 ++buf.position();
859 return ReturnType(true);
860 }
861
862 if (*buf.position() == '\\')
863 parseJSONEscapeSequence<Vector, ReturnType>(s, buf);
864 }
865
866 return error("Cannot parse JSON string: expected closing quote", ErrorCodes::CANNOT_PARSE_QUOTED_STRING);
867}
868
869void readJSONString(String & s, ReadBuffer & buf)
870{

Callers 7

readJSONStringFunction · 0.85
skipJSONFieldFunction · 0.85
readColumnNameMethod · 0.85
deserializeTextJSONMethod · 0.85
deserializeTextJSONMethod · 0.85
deserializeTextJSONMethod · 0.85
deserializeTextJSONMethod · 0.85

Calls 7

ParsingExceptionClass · 0.85
appendToStringOrVectorFunction · 0.85
bufferMethod · 0.80
hasPendingDataMethod · 0.80
eofMethod · 0.45
positionMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected