/src/serenity/AK/JsonParser.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/GenericLexer.h> |
10 | | #include <AK/JsonValue.h> |
11 | | |
12 | | namespace AK { |
13 | | |
14 | | class JsonParser : private GenericLexer { |
15 | | public: |
16 | | explicit JsonParser(StringView input) |
17 | 6.25k | : GenericLexer(input) |
18 | 6.25k | { |
19 | 6.25k | } |
20 | | |
21 | | ErrorOr<JsonValue> parse(); |
22 | | |
23 | | private: |
24 | | ErrorOr<JsonValue> parse_helper(); |
25 | | |
26 | | ErrorOr<ByteString> consume_and_unescape_string(); |
27 | | ErrorOr<JsonValue> parse_array(); |
28 | | ErrorOr<JsonValue> parse_object(); |
29 | | ErrorOr<JsonValue> parse_number(); |
30 | | ErrorOr<JsonValue> parse_string(); |
31 | | ErrorOr<JsonValue> parse_false(); |
32 | | ErrorOr<JsonValue> parse_true(); |
33 | | ErrorOr<JsonValue> parse_null(); |
34 | | }; |
35 | | |
36 | | } |
37 | | |
38 | | #if USING_AK_GLOBALLY |
39 | | using AK::JsonParser; |
40 | | #endif |