summaryrefslogtreecommitdiff
path: root/AK/JsonParser.h
blob: 76f7d7e5bfacc1a6a289678fd67692784dddd931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include <AK/JsonValue.h>

namespace AK {

class JsonParser {
public:
    explicit JsonParser(const StringView& input)
        : m_input(input)
    {
    }
    ~JsonParser()
    {
    }

    JsonValue parse();

private:
    char peek() const;
    char consume();
    void consume_whitespace();
    void consume_specific(char expected_ch);
    void consume_string(const char*);
    String consume_quoted_string();
    JsonValue parse_array();
    JsonValue parse_object();
    JsonValue parse_number();
    JsonValue parse_string();
    JsonValue parse_false();
    JsonValue parse_true();
    JsonValue parse_null();
    JsonValue parse_undefined();

    template<typename C>
    void consume_while(C);

    template<typename C>
    String extract_while(C);

    StringView m_input;
    int m_index { 0 };
};

}

using AK::JsonParser;