3#include <userver/formats/json/parser/typed_parser.hpp>
9template <
typename Map,
typename ValueParser>
12 using Value =
typename Map::mapped_type;
14 explicit MapParser(ValueParser& value_parser) : value_parser_(value_parser) {}
16 void Reset()
override {
this->state_ = State::kStart; }
18 void StartObject()
override {
21 this->state_ = State::kInside;
29 void Key(std::string_view key)
override {
30 if (state_ != State::kInside)
this->Throw(
"object");
33 this->value_parser_.Reset();
34 this->value_parser_.Subscribe(*
this);
35 this->parser_state_->PushParser(
this->value_parser_.GetParser());
38 void EndObject()
override {
39 if (state_ == State::kInside) {
40 this->SetResult(std::move(result_));
47 std::string Expected()
const override {
60 void OnSend(Value&& value)
override {
this->result_.emplace(std::move(key_), std::move(value)); }
62 std::string GetPathItem()
const override {
return key_; }
71 ValueParser& value_parser_;