I have an url,get and response given. I have to parse the JSON and show the locations in Map in android. I dont need you to code. I am new in JSON. please tell me some steps how i can do that. how should i start and which steps i should take?
Url: "Some url"
Sending data:
{
"tag": "getAvailableDriver",
"lat": 41.022348,
"lng": -91.966721
}
RESPONSE:
{
"posts": [
{
"success": "1",
"driver": [
{
"id": "768",
"lat": "41.022848",
"lon": "-91.966884",
"recorded_datetime": "2014-07-20 20:18:03",
"user_id": "403",
"cabbi_state": "OnJob",
"vehicleType": "Black Cab",
"driver_name": "black cab driver",
"pic_name": "userimage/403.jpg",
"rating": "0",
"car_model": "this",
"number_sit": "4",
"distance": 0.035574527536789
}
],
"operator": [],
"nearestdistance": [
{
"distance": 0.03541809,
"time": 5
}
],
"car_models": [
"Taxi"
]
}
]
}
I just want anyone of you to guide me or show me the way. And also please someone tell me what will be the use of "send data" here. What is the use? I promise i will not ask any basic questions after i catch the grip. Help me please.
You can save the parsed data in an array, and for what I can see, there's a lot of tags in the JSON object. I suggest you to create an object of the type "Driver" or "Car", and then save all the data in that object. Once you have the data parsed and saved in an Array of the type of your object (Let's say an array of "Drivers" then you can use the info to add it into the Map.
Related
I am trying to fetch JSON Object which has 2 list object with the same name, but has a different value. The object list named "items", the first "items" has "products_title,product_image,link", and the second "items" has "article_title, article_image,link". How to write PODO ?
I've been trying to writes PODO, but even i try to change the model, it still does not work. I try the other REST API, for the example "https://jsonplaceholder.typicode.com/pothos" its working fine. But if i try used my JSON its getting error, i wonder how to write PODO ?
this is the JSON i am using :
{
"data": [
{
"section": "electronics",
"items": [
{
"product_name": "Cellphone",
"product_image": "cellphoneImage.png",
"link": "https://cellphone.html"
},
]
},
{
"section": "facts",
"section_title": "Title section",
"items": [
{
"article_title": "Facts",
"article_image": "https://www.facts.png",
"link": "https://www.facts.html"
},
]
}
]
}
I am trying to make an app showing info from an API. I have searched everywhere but I didn't find an answer that solve my problem!
Here is an example from the JSON file:
{
"status": 200,
"data": {
"date": "2018-10-12T00:00:00.000Z",
"featured": [
{
"id": "5bbdc3abdf819b65ea6b733b",
"name": "Name",
"price": "1",
"priceIcon": "priceicon",
"priceIconLink": "price.png",
"images": {
"icon": "icon.png",
"png": false,
"gallery": false,
"featured": false
},
"rarity": "rarity",
"type": "type",
"readableType": "Type"
}
]
}
}
How can I fetch the name, price, icon, rarity and readableType?
Please don't mark it as duplicate because I haven't found the answer that I am searching for.
Check this tutorial, no one is going to code it for you, also your question has been made 10000 times
Tutorial
Suppose I have data in JSON. How can I parse the data so I can get the values of nested objects (e.g. kind, id and title)?
My JSON data is:
{
"kind": "youtube#playlistItemListResponse",
"items": [
{
"id": "UExkc1JWcGJNV19LSH",
"items":[
{
"title": "New Updates",
}
],
}],
}
Well you should remove all the commas since last items should not be followed by one.
So more like:
{
"kind": "youtube#playlistItemListResponse",
"items": [{
"id": "UExkc1JWcGJNV19LSH",
"items": [{
"title": "New Updates"
}]
}]
}
Other than that you can just use JSONObject lib and extract the value you need. For example to get the kind:
JSONObject jsonObj = new JSONObject(strInput);
String kind = jsonObj.getString("kind"); // kind now contains "youtube#playlistItemListResponse"
where strInput is the above json as a string.
More info: https://developer.android.com/reference/org/json/JSONObject
I would like to perform a request to OSM Overpass Turbo API or Overpass API from and Android Application so i can get the buildings around and area using JSON.
Something similar to
http://overpass-turbo.eu/ with the query presented below:
[out:json][timeout:25];
// gather results
(
// query part for: “building”
way["building"](37.98350674557998,23.72600823640823,37.98552989685638,23.728837966918945);
relation["building"](37.98350674557998,23.72600823640823,37.98552989685638,23.728837966918945);
);
// print results
out body;
>;
out skel qt;
The thing is that i need the results in geojson like the result below but i cannot find any query that gives me the below result.
{
"type": "FeatureCollection",
"generator": "overpass-turbo",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.",
"timestamp": "2015-03-23T20:41:02Z",
"features": [
{
"type": "Feature",
"id": "relation/2604192",
"properties": {
"#id": "relation/2604192",
"building": "yes",
"type": "multipolygon"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
23.7319885,
37.9752441
],
[
23.7319787,
37.9751612
],
[
23.7319494,
37.9751641
],
[
23.7319372,
37.9748376
],
[
23.7319702,
37.9748318
],
]
]
}
},
I get only results with nodes but not with geometry.
{
"type": "way",
"id": 25107859,
"nodes": [
2373953582,
2373953586,
2373953592,
2373953599,
2373953597,
2373953636,
2373953633,
2373953626,
273319309,
2373953582
],
"tags": {
"building": "yes"
}
},
After some useful comments (thanks scai) i found out that overpass turbo is not queried automatically. Therefore i searched for overpass api and i found out this site with a query for buildings to overpass api exporting to GeoJSON but i does not work (though the xml query in the site works but i need json). Anyone has a query that works so i can follow it?
http://inasafe.org/en/developer-docs/osm_building_downloads.html
http://overpass-api.de/api/interpreter?data=[out:json];(node[%23building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725);way[%22building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725);relation[%22building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725););(._;%3E;);out%20body;
How I can get the cover photo of the albums of a user in my application?
Currently, I have a json like this:
"id": "00000",
"albums": {
"data": [
{
"id": "428076573767",
"from": {
"name": "Benjamin",
"id": "00000"
},
"name": "Profile Pictures",
"link": "https://www.facebook.com/album.php?fbid=00000&id=00000&aid=00000",
"cover_photo": "10151465301937683",
"privacy": "everyone",
"count": 57,
"type": "profile",
"created_time": "2010-09-05T08:42:19+0000",
"updated_time": "2013-04-27T23:53:11+0000",
"can_upload": false
},
}
How I can get the cover_photo by URL?
You can get cover photo by adding this into URL. No need to extract cover_photo from Json .
album['id']?>/picture?access_token=12345
// where album is JSON array and access_token is random here..
Try this. It will work.