I need to send data to Algolia from my Android, the data sent should be in JSONObject format (import org.json.JSONObject)
the data in Algolia should be in this format
"_geoloc": {
"lat": 40.639751,
"lng": -73.778925
}
so in Android, I set the code like this
val jsonObject = JSONObject()
val locHashMap = hashMapOf(
"lat" to coordinate.latitude,
"lng" to coordinate.longitude
)
jsonObject.put("_geoloc",locHashMap)
index.addObjectAsync(jsonObject)
but unfortunately, I get this error:
java.lang.NoSuchMethodError: No virtual method put(Ljava/lang/String;Ljava/util/Map;)Lorg/json/JSONObject; in class Lorg/json/JSONObject; or its super classes (declaration of 'org.json.JSONObject' appears in /system/framework/core-libart.jar)
in this line of code jsonObject.put("_geoloc",locHashMap)
so what should I do in order to send hashmap data in JSONObject format ?