-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_utils.h
52 lines (35 loc) · 1.28 KB
/
json_utils.h
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
#ifndef JSON_UTILS_H
#define JSON_UTILS_H
#include "reddit_types.pb.h"
#include <string>
namespace google {
namespace protobuf {
class Message;
class FieldDescriptor;
}; // namespace google::protobuf
}; // namespace google
namespace Json {
class Value;
}; // namespace Json
namespace reddit {
Json::Value StringToJson(const std::string& str);
bool JsonHasErrors(const Json::Value& json);
Comment JsonToComment(const Json::Value& json);
Account JsonToAccount(const Json::Value& json);
Link JsonToLink(const Json::Value& json);
Message JsonToMessage(const Json::Value& json);
Subreddit JsonToSubreddit(const Json::Value& json);
Listing JsonToListing(const Json::Value& json);
More JsonToMore(const Json::Value& json);
Thing JsonToThing(const Json::Value& json);
LoginResponse JsonToLoginResponse(const Json::Value& json);
void SetMessageFromJson(google::protobuf::Message* msg,
const Json::Value& json);
void MaybeSetField(google::protobuf::Message* msg,
const google::protobuf::FieldDescriptor* field,
const Json::Value& json_val);
void MaybeAddField(google::protobuf::Message* msg,
const google::protobuf::FieldDescriptor* field,
const Json::Value& json_val);
}; // namespace reddit
#endif