blob: cd3b4608b1a91ff190209fc4bfd8efc418688ab5 (
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
28
29
30
31
32
33
34
|
#include <mbgl/style/conversion/get_json_type.hpp>
#include <mbgl/util/feature.hpp>
namespace mbgl {
namespace style {
namespace conversion {
std::string getJSONType(const Convertible& value) {
if (isUndefined(value)) {
return "null";
}
if (isArray(value)) {
return "array";
}
if (isObject(value)) {
return "object";
}
optional<mbgl::Value> v = toValue(value);
// Since we've already checked the non-atomic types above, value must then
// be a string, number, or boolean -- thus, assume that the toValue()
// conversion succeeds.
assert(v);
return v->match(
[&] (const std::string&) { return "string"; },
[&] (bool) { return "boolean"; },
[&] (auto) { return "number"; }
);
}
} // namespace conversion
} // namespace style
} // namespace mbgl
|