2019-06-24 11:38:59 +00:00
|
|
|
#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();
|
2019-08-04 09:47:21 +00:00
|
|
|
JsonArray parse_array();
|
|
|
|
JsonObject parse_object();
|
2019-06-24 11:38:59 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
StringView m_input;
|
|
|
|
int m_index { 0 };
|
2019-08-04 16:22:41 +00:00
|
|
|
|
|
|
|
String m_last_string_starting_with_character[256];
|
2019-06-24 11:38:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using AK::JsonParser;
|