mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:37:34 +00:00
AK: Let's put the JSON parsing in a separate class.
This commit is contained in:
parent
8392c549a3
commit
266fed8c00
4 changed files with 235 additions and 162 deletions
47
AK/JsonParser.h
Normal file
47
AK/JsonParser.h
Normal file
|
@ -0,0 +1,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;
|
Loading…
Add table
Add a link
Reference in a new issue