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
Related
We are currently working on project where a web user creates a survey which has cascading questions (cascading means questions that have few answers and depend on those answers rest of the questions changes) and then mobile users should get this survey in their android app. Sample JSON structure we thought is as follows:
{
"status": "1",
"tabs": [
"Farmer Information",
"Signature",
"Crop Details",
"Land Parcel"
],
"survey":[
{
"type": "TextView",
"cascade": "0",
"value": "What is your name?",
"survey": ""
},
{
"type": "TextView",
"cascade": "0",
"value": "What is your age?",
"survey" : ""
},
{
"type": "RadioButtonGroup",
"cascade": "1",
"value": "Do you have kids?",
"survey" : [
{
"type": "TextView",
"cascade": "1",
"value": "YES",
"survey": [
{
"type": "TextView",
"cascade": "1",
"value": "How many of them below 18?",
"survey": ""
},
{
"type": "TextView",
"cascade": "0",
"value": "How many of them are girls?",
"survey" : ""
},
{
"type": "TextView",
"cascade": "1",
"value": "Where do you live in?",
"survey": ""
},
{
"type": "TextView",
"cascade": "0",
"value": "How long you were there?",
"survey" : ""
}
]
},
{
"type": "TextView",
"cascade": "0",
"value": "NO",
"survey" : [
{
"type": "TextView",
"cascade": "1",
"value": "Where do you live in?",
"survey": ""
},
{
"type": "TextView",
"cascade": "0",
"value": "How long you were there?",
"survey" : ""
}
]
}
]
}
]
}
Is there anyway to achieve such a thing?
What are the most suitable library which can be used for this scenario? We tried json2view, proteus. From all those we can pass a json and load the view but if there are cascading questions non of them can use.
Furthermore elaborating in the question via an example:
Suppose the user is given the question of Do you have any have kids?. This question has possible two answers. Yes & No depending upon the answer which user give others questions have to be loaded dynamically.
This may be too late, but here goes. This can be done in proteus.
Philosophy: How would you do it in Native Android?
By creating a custom view, let call it SurveyView which has 3 custom attributes
status: initial condition
cascade: the check condition
survey: array of child SurveyView
So, in Native Android, there would be a method setStatus() which will be called when an answer is selected. This will set the status of the child survey views. The child will check the new status against the condition set on them. If it matches, it is visible else gone.
After this simply register this as a custom view with proteus. There is a slightly more complicated way of doing this without a custom view (by using function bindings in like so.
{
"visibility: "#{fn:eq(#{data.status}, 0)}"
}
Where data.status is the status propagated down from the parent and 0 is the cascade condition. You get the drift.
fn:eq is a built-in function. Check here for all available functions here
You can create and register your own custom functions too.
P.S. why not react native?
P.P.S Use proteus tag in questions related to proteus, this is why I missed this.
I'm trying to set up CI for Gradle based Android project with Bamboo. Tutorial here work just work great for successful build.
For release note following I figure out to get Git log between two revision number.
git log ${bamboo.repository.previous.revision.number}..${bamboo.repository.revision.number}
But how to get last successful build git_revision number & current one.
Any suggestion ?
This involves scripting and utilizing REST API of Bamboo https://docs.atlassian.com/bamboo/REST [Choose the version you are working with]
To get all the build results, you need to make a call to:
[GET] <basepath>/rest/api/latest/result/{projectKey}-{buildKey}
Where, basepath is http://myhost.com:8085 OR http://myhost.com:8085/bamboo
Resulting in below:
{
"results": {
"size": 8,
"expand": "result",
"start-index": 0,
"max-result": 25,
"result": [
{
"link": {
"href": "<basepath>/rest/api/latest/result/{projectKey}-{buildKey}-{buildNumber}",
"rel": "self"
},
"plan": {
"shortName": "xyz",
"shortKey": "{buildKey}",
"type": "chain",
"enabled": true,
"link": {
"href": "<basepath>/rest/api/latest/plan/DS-ASVCCRED",
"rel": "self"
},
"key": "{projectKey}-{buildKey}",
"name": "ABCD",
"planKey": {
"key": "{projectKey}-{buildKey}"
}
},
"buildResultKey": "{projectKey}-{buildKey}-{buildNumber}",
"lifeCycleState": "Finished",
"id": 198039818,
"key": "{projectKey}-{buildKey}-{buildNumber}",
"planResultKey": {
"key": "{projectKey}-{buildKey}-{buildNumber}",
"entityKey": {
"key": "{projectKey}-{buildKey}"
},
"resultNumber": 45
},
"state": "Failed",
"buildState": "Failed",
"number": 45,
"buildNumber": 45
},
If JSON output is desired, just add Accept=application/json header while making a call.
This will return latest 25 build results in a sequence with the latest result being the first. You may go through this results and decide which two build results you are interested in.
Once you decide, you make additional calls to get change set (commit details) captured by bamboo for that particular build.
[GET] <basepath>/rest/api/latest/result/{projectKey}-{buildKey}/{buildNumber : ([0-9]+)|(latest)}?expand=changes
This will give you detailed commit description as below:
"changes": {
"size": 3,
"expand": "change",
"change": [
{
"author": "1234",
"changesetId": "7f76c41a7ff48f679a91d0fa2810ef3398121dc6"
},
{
"author": "abcd",
"changesetId": "104d8b7af9538599a02006005314033c8017e804"
},
{
"author": "cdef",
"changesetId": "d21aef9f3745257aa501425fc31ebd0c6b33f608"
}
],
"start-index": 0,
"max-result": 3
},
And then you can perform
git log <changesetId>...<changesetId>
My json file that have data
[
{
"id": 19,
"name": "Science",
"quiz": "quiz6"
},
{
"id": 21,
"name": "general knowledge",
"quiz": "For banking"
},
{
"id": 26,
"name": "Technologies",
"quiz": "arithmatic"
},
{
"id": 27,
"name": "english",
"quiz": "abcde"
},
{
"id": 28,
"name": "computer",
"quiz": "basic Question"
}
]
save on a server.Now i want to parse it in phonegap(android).How to do that.
When I save that file on my project and use it then it work, but when i use that file directly on server site then its not working.Is there any permission or plugin needed to access json on server side.
If in url i pass the "http://some folders/places.php" then it not work.
Thanks to all. Its working now.I try it on phone and its working.Actually my AVG software block my emulator to access the internet. Thats why it was not working.
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.
I was wondering how to get the value of "name" for the following json text with facebook sdk. Assuming I have already got the access token. Any thoughts? Many thanks!
enter code here
{
"id": "100005065353669",
"music": {
"data": [
{
"category": "Musician/band",
"name": "Eason Chan",
"id": "105468519487919",
"created_time": "2013-06-05T20:33:26+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/100005065353669/musiclimit=5000&offset=5000&__after_id=105468519487919"
}
}
}