#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/json/json_parser.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/renderer/platform/json/json_values.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_to_number.h"
namespace blink {
namespace {
const int kMaxStackLimit = …;
Error;
String FormatErrorMessage(Error error, int line, int column) { … }
template <typename CharType>
struct Cursor { … };
enum Token { … };
template <typename CharType>
Error ParseConstToken(Cursor<CharType>* cursor,
const CharType* end,
const char* token) { … }
template <typename CharType>
Error ReadInt(Cursor<CharType>* cursor,
const CharType* end,
bool can_have_leading_zeros) { … }
template <typename CharType>
Error ParseNumberToken(Cursor<CharType>* cursor, const CharType* end) { … }
template <typename CharType>
Error ReadHexDigits(Cursor<CharType>* cursor, const CharType* end, int digits) { … }
template <typename CharType>
Error ParseStringToken(Cursor<CharType>* cursor, const CharType* end) { … }
template <typename CharType>
Error SkipComment(Cursor<CharType>* cursor, const CharType* end) { … }
template <typename CharType>
Error SkipWhitespaceAndComments(Cursor<CharType>* cursor,
const CharType* end,
JSONCommentState& comment_state) { … }
template <typename CharType>
Error ParseToken(Cursor<CharType>* cursor,
const CharType* end,
Token* token,
Cursor<CharType>* token_start,
JSONCommentState& comment_state) { … }
template <typename CharType>
inline int HexToInt(CharType c) { … }
template <typename CharType>
Error DecodeString(Cursor<CharType>* cursor,
const CharType* end,
String* output) { … }
template <typename CharType>
Error BuildValue(Cursor<CharType>* cursor,
const CharType* end,
int max_depth,
JSONCommentState& comment_state,
std::unique_ptr<JSONValue>* result,
Vector<String>* duplicate_keys) { … }
template <typename CharType>
JSONParseError ParseJSONInternal(const CharType* start_ptr,
unsigned length,
int max_depth,
JSONCommentState& comment_state,
std::unique_ptr<JSONValue>* result) { … }
}
std::unique_ptr<JSONValue> ParseJSON(const String& json,
JSONParseError* opt_error) { … }
std::unique_ptr<JSONValue> ParseJSONWithCommentsDeprecated(
const String& json,
JSONParseError* opt_error,
bool* opt_has_comments) { … }
std::unique_ptr<JSONValue> ParseJSON(const String& json,
JSONCommentState& comment_state,
int max_depth,
JSONParseError* opt_error) { … }
}