diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/src/style/android_conversion.hpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/platform/android/src/style/android_conversion.hpp b/platform/android/src/style/android_conversion.hpp index dc0a0acb31..6f16804597 100644 --- a/platform/android/src/style/android_conversion.hpp +++ b/platform/android/src/style/android_conversion.hpp @@ -110,11 +110,31 @@ public: } static optional<GeoJSON> toGeoJSON(const mbgl::android::Value &value, Error &error) { - if (value.isNull() || !value.isString()) { + if (value.isNull()) { error = { "no json data found" }; return {}; } - return parseGeoJSON(value.toString(), error); + + if (value.isString()) { + return parseGeoJSON(value.toString(), error); + } + + if (value.isObject()) { + mbgl::android::Value keys = value.keyArray(); + std::size_t length = arrayLength(keys); + for (std::size_t i = 0; i < length; ++i) { + if (keys.get(i).toString() == "json") { + auto v = value.get("json"); + if (v.isString()) { + return parseGeoJSON(v.toString(), error); + } else { + break; + } + } + } + } + error = {"no json data found"}; + return {}; } }; |