1
#pragma once
2

            
3
#include <string>
4

            
5
#include "envoy/json/json_object.h"
6

            
7
#include "source/common/common/statusor.h"
8
#include "source/common/protobuf/protobuf.h"
9

            
10
#include "absl/container/flat_hash_map.h"
11
#include "absl/container/flat_hash_set.h"
12

            
13
namespace Envoy {
14
namespace Json {
15

            
16
class Factory {
17
public:
18
  /**
19
   * Constructs a Json Object from a string.
20
   */
21
  static absl::StatusOr<ObjectSharedPtr> loadFromString(const std::string& json);
22

            
23
  /**
24
   * Constructs a Json Object from a Protobuf struct.
25
   */
26
  static ObjectSharedPtr loadFromProtobufStruct(const Protobuf::Struct& protobuf_struct);
27

            
28
  /*
29
   * Serializes a JSON string to a byte vector using the MessagePack serialization format.
30
   * If the provided JSON string is invalid, an empty vector will be returned.
31
   * See: https://github.com/msgpack/msgpack/blob/master/spec.md
32
   */
33
  static std::vector<uint8_t> jsonToMsgpack(const std::string& json);
34

            
35
  /*
36
   * Constructs a JSON string from a list of strings.
37
   */
38
  static const std::string listAsJsonString(const std::list<std::string>& items);
39
};
40

            
41
} // namespace Json
42
} // namespace Envoy