blob: fbda37b4e7791a870cf6d8df421015fdef37b04a (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "jsonconfigformatter.h"
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/data/slime/json_format.h>
#include <vespa/vespalib/data/simple_buffer.h>
using vespalib::SimpleBuffer;
using vespalib::Output;
using vespalib::slime::JsonFormat;
namespace config {
JsonConfigFormatter::JsonConfigFormatter(bool compact)
: _compact(compact)
{
}
void
JsonConfigFormatter::encode(ConfigDataBuffer & buffer) const
{
SimpleBuffer buf;
JsonFormat::encode(buffer.slimeObject(), buf, _compact);
buffer.setEncodedString(buf.get().make_string());
}
size_t
JsonConfigFormatter::decode(ConfigDataBuffer & buffer) const
{
std::string ref(buffer.getEncodedString());
return JsonFormat::decode(ref, buffer.slimeObject());
}
} // namespace config
|