123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #ifndef BASE_JSON_JSON_READER_H_
- #define BASE_JSON_JSON_READER_H_
- #include <memory>
- #include <string>
- #include "base/base_export.h"
- #include "base/json/json_common.h"
- #include "base/optional.h"
- #include "base/strings/string_piece.h"
- #include "base/values.h"
- namespace base {
- enum JSONParserOptions {
-
-
- JSON_PARSE_RFC = 0,
-
- JSON_ALLOW_TRAILING_COMMAS = 1 << 0,
-
-
-
-
- JSON_REPLACE_INVALID_CHARACTERS = 1 << 1,
- };
- class BASE_EXPORT JSONReader {
- public:
- struct BASE_EXPORT ValueWithError {
- ValueWithError();
- ValueWithError(ValueWithError&& other);
- ValueWithError& operator=(ValueWithError&& other);
- ~ValueWithError();
- Optional<Value> value;
-
-
- std::string error_message;
- int error_line = 0;
- int error_column = 0;
- DISALLOW_COPY_AND_ASSIGN(ValueWithError);
- };
-
-
- static Optional<Value> Read(StringPiece json,
- int options = JSON_PARSE_RFC,
- size_t max_depth = internal::kAbsoluteMaxDepth);
-
-
-
-
-
- static std::unique_ptr<Value> ReadDeprecated(
- StringPiece json,
- int options = JSON_PARSE_RFC,
- size_t max_depth = internal::kAbsoluteMaxDepth);
-
-
-
- static ValueWithError ReadAndReturnValueWithError(
- StringPiece json,
- int options = JSON_PARSE_RFC);
-
- JSONReader() = delete;
- DISALLOW_COPY_AND_ASSIGN(JSONReader);
- };
- }
- #endif
|