summaryrefslogtreecommitdiff
path: root/src/mbgl/style/conversion/json.hpp
blob: 4e7ad9479aac2c1518f3809a023bf10bce63a1f0 (plain)
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
#pragma once

#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/style/rapidjson_conversion.hpp>

#include <string>

namespace mbgl {
namespace style {
namespace conversion {

template <class T, class...Args>
optional<T> convertJSON(const std::string& json, Error& error, Args&&...args) {
    JSDocument document;
    document.Parse<0>(json.c_str());

    if (document.HasParseError()) {
        error = { formatJSONParseError(json, document) };
        return {};
    }

    return convert<T>(document, error, std::forward<Args>(args)...);
}

} // namespace conversion
} // namespace style
} // namespace mbgl