MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / parse

Function parse

include/jsoncons/basic_json.hpp:1978–2001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1976
1977 template <typename Source>
1978 static
1979 typename std::enable_if<ext_traits::is_string_view_of<Source,char_type>::value,basic_json>::type
1980 parse(const Source& source,
1981 const basic_json_decode_options<char_type>& options = basic_json_options<char_type>())
1982 {
1983 json_decoder<basic_json> decoder;
1984 basic_json_parser<char_type> parser(options);
1985
1986 auto r = unicode_traits::detect_encoding_from_bom(source.data(), source.size());
1987 if (!(r.encoding == unicode_traits::encoding_kind::utf8 || r.encoding == unicode_traits::encoding_kind::undetected))
1988 {
1989 JSONCONS_THROW(ser_error(json_errc::illegal_unicode_character,parser.line(),parser.column()));
1990 }
1991 std::size_t offset = (r.ptr - source.data());
1992 parser.update(source.data()+offset,source.size()-offset);
1993 parser.parse_some(decoder);
1994 parser.finish_parse(decoder);
1995 parser.check_done();
1996 if (JSONCONS_UNLIKELY(!decoder.is_valid()))
1997 {
1998 JSONCONS_THROW(ser_error(json_errc::source_error, "Failed to parse json string"));
1999 }
2000 return decoder.get_result();
2001 }
2002
2003 template <typename Source,typename TempAlloc >
2004 static

Callers 15

LLVMFuzzerTestOneInputFunction · 0.85
serialization_example1Function · 0.85
serialization_example3Function · 0.85
serialization_example4Function · 0.85
dump_json_fragmentsFunction · 0.85
nan_inf_replacementFunction · 0.85
bignum_access_examplesFunction · 0.85
cbor_tests.cppFile · 0.85

Calls 15

detect_encoding_from_bomFunction · 0.85
ser_errorClass · 0.85
get_resultMethod · 0.80
get_temp_allocatorMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
lineMethod · 0.45
columnMethod · 0.45
updateMethod · 0.45
parse_someMethod · 0.45
finish_parseMethod · 0.45
check_doneMethod · 0.45

Tested by 15

jmespath_testsFunction · 0.68
json_merge_patch_testsFunction · 0.68
toon_encode_testsFunction · 0.68
toon_decode_testsFunction · 0.68
test_json_reader_errorFunction · 0.68
test_parse_errorFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
jsonpath_testsFunction · 0.68
resolverFunction · 0.68
jsonschema_testsFunction · 0.68
resolverFunction · 0.68
jsonschema_testsFunction · 0.68