blob: 8d23ba8e2ee334c72e265a660d6593d84d07e8b2 (
plain) (
blame)
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
48
49
50
51
52
53
|
#pragma once
#include <library/cpp/yson/consumer.h>
#include <library/cpp/json/json_reader.h>
#include <util/generic/stack.h>
namespace NYT {
class TYson2JsonCallbacksAdapter
: public NJson::TJsonCallbacks {
public:
class TState {
private:
// Stores current context stack
// If true - we are in a list
// If false - we are in a map
TStack<bool> ContextStack;
friend class TYson2JsonCallbacksAdapter;
};
public:
TYson2JsonCallbacksAdapter(::NYson::TYsonConsumerBase* impl, bool throwException = false);
bool OnNull() override;
bool OnBoolean(bool val) override;
bool OnInteger(long long val) override;
bool OnUInteger(unsigned long long val) override;
bool OnString(const TStringBuf& val) override;
bool OnDouble(double val) override;
bool OnOpenArray() override;
bool OnCloseArray() override;
bool OnOpenMap() override;
bool OnCloseMap() override;
bool OnMapKey(const TStringBuf& val) override;
TState State() const {
return State_;
}
void Reset(const TState& state) {
State_ = state;
}
private:
void WrapIfListItem();
private:
::NYson::TYsonConsumerBase* Impl_;
TState State_;
};
}
|