Mainank Brahmbhatt
Mainank Brahmbhatt

Reputation: 732

Augmented Reality

If POI's are in my database like POINT(-lat long) for locations in my database then how to pass the database data in mixare with in json structure.

These is the json structure: http://code.google.com/p/mixare/wiki/DisplayYourOwnData

please suggest me some output with steps as quick as possible?

Upvotes: 2

Views: 600

Answers (1)

Lalit Poptani
Lalit Poptani

Reputation: 67286

I would insist you to use GSON in this case and fetch the data from database into HashMap/List or any collection which would be easily converted to JSONObject or JSONArray,

For eg:-

Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "Sriram");
map.put("age", 2);
map.put("dob", new Date(110, 4, 6));
map.put("hobby", "painting");

Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonStr = gson.toJson(map);
System.out.println(jsonStr);

OUTPUT:

{
  "dob": "May 6, 2010 12:00:00 AM",
  "age": 2,
  "name": "Sriram",
  "hobby": "painting"
}

Checkout this link for further converstion from collection to JSON and JSON to collections.

Upvotes: 5

Related Questions