未验证 提交 e25017b0 编写于 作者: L Leandro A. F. Pereira 提交者: GitHub

host: Allow comments in JSON files (#1070)

host: Allow comments in JSON files
......@@ -84,9 +84,11 @@ bool json_parser_t::parse_json(const pal::string_t& context)
// UTF-8 and the host expects wide strings. m_document will store
// data in UTF-16 (with pal::char_t as the character type), but it
// has to know that data is encoded in UTF-8 to convert during parsing.
m_document.Parse<rapidjson::ParseFlag::kParseStopWhenDoneFlag, rapidjson::UTF8<>>(m_json.data());
constexpr auto flags = rapidjson::ParseFlag::kParseStopWhenDoneFlag
| rapidjson::ParseFlag::kParseCommentsFlag;
m_document.Parse<flags, rapidjson::UTF8<>>(m_json.data());
#else
m_document.ParseInsitu(m_json.data());
m_document.ParseInsitu<rapidjson::ParseFlag::kParseCommentsFlag>(m_json.data());
#endif
if (m_document.HasParseError())
......
{
"runtimeOptions": {
/* This is a multiline comment to test that the JSON parser is correctly
* set up to ignore them. */
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9999.0.0"
"name": "Microsoft.NETCore.App", // And this is a single-line comment
"version": "9999.0.0" // that should be ignored by the parser
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册