This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I'd like to parse the following information and would like to identify the format that it is in?
{
"interval": {
"id": 0,
"starts_at": 1317851120683,
"ends_at": 1317851374436
},
"identifier": "2021902",
"category": "music",
"original_category": "",
"buy_link": "http://click.linksynergy.com/fs-bin/stat?id=6z5Z0DsswBo&offerid=162397&type=3&subid=0&tmpid=3664&RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fca%252Falbum%252Foh-my-what-a-fine-day%252Fid360945836%253Fi%253D360945883%2526uo%253D4%2526partnerId%253D30",
"title": "Oh My, What A Fine Day",
"artist": "Behind Sapphire",
"album": "Behind Sapphire",
"publisher": "Behind Sapphire",
"itunes_song_id": "360945883",
"album_art": {
"src": "http://www.streamon.fm/player/getAlbumArt.php?u=http://a4.mzstatic.com/us/r30/Music/fc/73/1d/mzi.briyobdw.170x170-75.jpg",
"width": 170,
"height": 170,
"alt": "Behind Sapphire",
"link": ""
},
"next_song": "",
"next_buy_link": "",
"next_album_art": {
"src": "",
"width": 0,
"height": 0,
"alt": "",
"link": ""
},
"banner": {
"src": "",
"width": 0,
"height": 0,
"alt": "",
"link": ""
}
}
JSON.
See this: http://developer.android.com/reference/org/json/package-summary.html
JSON, or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange.
You can refer to wikipedia, and you could get some useful information
JSON. In this web http://www.json.org/ you can found a extensive index of libs for parse this information.
Related
I want to receive emoticon from emoji-datasource site as json file and show it in android. How do you do it? The file in json format is:
[
{
"name": "HASH KEY",
"unified": "0023-FE0F-20E3",
"non_qualified": "0023-20E3",
"docomo": "E6E0",
"au": "EB84",
"softbank": "E210",
"google": "FE82C",
"image": "0023-fe0f-20e3.png",
"sheet_x": 0,
"sheet_y": 0,
"short_name": "hash",
"short_names": [
"hash"
],
"text": null,
"texts": null,
"category": "Symbols",
"sort_order": 132,
"added_in": "0.0",
"has_img_apple": true,
"has_img_google": true,
"has_img_twitter": true,
"has_img_facebook": false
},
{
"name": null,
"unified": "002A-FE0F-20E3",
"non_qualified": "002A-20E3",
"docomo": null,
"au": null,
"softbank": null,
"google": null,
"image": "002a-fe0f-20e3.png",
"sheet_x": 0,
"sheet_y": 1,
"short_name": "keycap_star",
"short_names": [
"keycap_star"
],
"text": null,
"texts": null,
"category": "Symbols",
"sort_order": 133,
"added_in": "0.0",
"has_img_apple": true,
"has_img_google": true,
"has_img_twitter": true,
"has_img_facebook": false
},
...
]
Link is here : https://www.npmjs.com/package/emoji-datasource.
I tried the following but it didn't work.
textView.text = String(Character.toChars(0x002AFE0F20E3))
I want to show the user all the emoticons available on the Android device.
Oh, I solved it. Just use in json file google name code.
I dont know that this would serve as a solution but I did something different and wanna share it here so everyone knows.
Content that I create from Android app gets encoded using this. When fetching from server, I decode this using the same method. Content includes emojis as well and they appear perfectly in all devices without knowing the names of the emojis.
This question already has answers here:
How to parse JSON in Kotlin?
(17 answers)
Closed 3 years ago.
I have a response json like this,
[{
"userId": 1,
"id": 1,
"title": "quidem molestiae enim"
},
{
"userId": 2,
"id": 2,
"title": "sunt qui excepturi placeat culpa"
},
{
"userId": 3,
"id": 3,
"title": "omnis laborum odio"
}]
I want to show detail from userId = 3, I wasn't provided an endpoint to get detail. So I want to get detail from this endpoint.
in App:
I've shown the data for dashboard (using recyclerview/list)
After that, I want to go to detail from one data that I selected.
Case: I'm using 1 endpoint (like above)
JSONArray jsonArray = (JSONArray) JSON.parse(str);
Map map = jsonArray.stream().map( obj -> {JSONObject jsonobject = (JSONObject) obj;return jsonobject;}).collect(Collectors.toMap(obj->obj.getIntValue("userId"),obj->obj.toJSONString()));
System.out.println(map.get(3));
the start point of json must always be a jsonObject not jsonArray. head to your backend developer and ask him or her to put your jsonArray inside a jsonObject.
{
"docs":[{
"userId": 1,
"id": 1,
"title": "quidem molestiae enim"
},
{
"userId": 2,
"id": 2,
"title": "sunt qui excepturi placeat culpa"
},
{
"userId": 3,
"id": 3,
"title": "omnis laborum odio"
}]
}
I'm trying to use the New york times api to show the headline and an image in a listview on android. I'm already getting the data for headline and date and outputting to log cat. The real problem is: whenever I put the extra field to get the mulimedia (images url) the "GC_FOR_ALLOC freed 1902K (64), 22% free 11931K/15156K" is shown
I've seen that the api always sends fixed number of 10 nyt articles, but each of the 10 has a multiple multimedia urls and json with arrays nested and the app freezes. I'll learn to put the data on listview on my own, my real question is, whats the best approach to fix the crash, I only want 1 url image per article.
//THE RETURNED JSON WITH ONLY "MULTIMEDIA" FIELD QUERY.
{
"status": "OK",
"copyright": "Copyright (c) 2018 The New York Times Company. All Rights
Reserved.",
"response": {
"docs": [
{
"multimedia": [
{
"rank": 0,
"subtype": "xlarge",
"caption": null,
"credit": null,
"type": "image",
"url": "images/2018/09/07/opinion/07Parcak/merlin_143215881_20cecc31-7c8d-4b8f-8541-773170c1822c-articleLarge.jpg",
"height": 400,
//MORE CODE HERE.. THEN NEXT ARRAY BELOW
{
"multimedia": [
{
"rank": 0,
"subtype": "xlarge",
"caption": null,
"credit": null,
"type": "image",
"url": "images/2018/09/03/world/03xp-brazil-promo/03xp-brazil-promo-articleLarge.jpg",
"height": 400,
"width": 600,
"legacy": {
"xlarge": "images/2018/09/03/world/03xp-brazil-promo/03xp-brazil-promo-articleLarge.jpg",
"xlargewidth": 600,
"xlargeheight": 400
},
"subType": "xlarge",
"crop_name": "articleLarge"
},
// Goes on forever.
What do you use to get the data, what kind of REST client are you using?
For example if you are parsing the response by yourself you can put some logic like
JSONObject obj = new JSONObject(" .... ");
JSONArray arr = obj.getJSONArray("multimedia");
JSONObject firstMultimedia = null;
if (arr.length() > 0){
firstMultimedia = arr.getJSONObject(0);
}
I am migrating to Firebase to help me retrieve my data. My question is how can I format my Firebase Database data like the JSON below. How can I specify objects like the JSON below?
[
{
"DoctorsName": "DR.LUTAAYA HUZAIFAH IDRIS",
"HealthCentreName": "Mulago",
"Specialisation": "Dentist",
"Information": "am genious",
"photo": "huzaifah.jpg",
"WorkingHours": "8:00am - 3:00pm",
"PhoneNumber": "0704594180",
"Email": "huxaiphaeridris#gmail.com"
},
{
"DoctorsName": "DR. G. WABULEMBO",
"HealthCentreName": "Kibuli",
"Specialisation": "Opthalmologist",
"Information": " is a consultant Opthalmologist with over 25 years experience in Canada and Uganda.",
"photo": "wabulembo.jpg",
"WorkingHours": "8:00am - 12:00pm",
"PhoneNumber": "0756478923",
"Email": "wabulembo#gmail.com"
},
{
"DoctorsName": "DR. BUKIRWA JAUHARAH",
"HealthCentreName": "Kibuli",
"Specialisation": "Urologist",
"Information": "Shes a Urologist , she has an experience of 7 years in Kibuli Hospital , and she studied in the United States Of America University",
"photo": "jauharah.jpg",
"WorkingHours": "10:00am - 4:00pm",
"PhoneNumber": "0706081457",
"Email": "bukijauha#gmail.com"
},
{
"DoctorsName": "DR. R. SEKITOLEKO",
"HealthCentreName": "Nakasero Hospital",
"Specialisation": "General Physician",
"Information": " is consultant physician with over 33 years of experience in Berlin and Hamburg (Germany) and Mulago Hospital (Uganda). He also practised as a consultant with WHO (2001-2003).",
"photo": "sekitoleko.jpg",
"WorkingHours": "12:00am - 7:00pm",
"PhoneNumber": "0765633667",
"Email": "sekitoleko#gmail.com"
},
{
"DoctorsName": "DR. A. MAKHOBA ",
"HealthCentreName": "Nakasero Hospital",
"Specialisation": "Cardiologist",
"Information": "is a consultant cardiologist,. He has practised for more than 20 years in Illinois and Wisconsin (USA) and for over two years in Uganda, at the Uganda Heart Institute and Nakasero Hospital.",
"photo": "makhoba.jpg",
"WorkingHours": "8:00am- 4:00pm",
"PhoneNumber": "0765453636",
"Email": "makhoba#gmail.com"
},
{
"DoctorsName": "DR.Sako Banabus",
"HealthCentreName": "Nakasero Hospital",
"Specialisation": "Dentist",
"Information": null,
"photo": "kamanzi.jpg",
"WorkingHours": "7:00pm - 3:00am",
"PhoneNumber": "0754369696",
"Email": "sw#gmail.com"
},
{
"DoctorsName": "DR. KAMANZI ABUBAKAR",
"HealthCentreName": "Mengo Hosiptal",
"Specialisation": "Neurosurgeon",
"Information": "Hes a Neurosurgeon, he has an experience of 20 years in Mengo Hospital , he studied in the Carlifornia University",
"photo": "kamanzi.jpg",
"WorkingHours": "7:00pm - 3:00am",
"PhoneNumber": "07003014850",
"Email": "kamanziabubakar75#gmail.com"
}
]
You can write pretty much any JSON you'd like directly to Firebase. For ease of retrieval though, you'd need to figure out some sort of schema. I'd recommend something like the following:
doctors
<docotrId>
- doctorId
- doctorName
- specialisation
- information
- photo
- phone
- email
- #healthCenter
healthCenters
<healthCenterId>
- centerId
- name
- #doctors[]
specialisationDoctors
<specialisationName>
<doctorId>
The first thing you need to do is map your data to this schema. You can create POJO classes, Maps, or even JSON formatted strings.
Then push your mapped data using setValue() on the appropriate nodes. Make sure to read the documentation for more information.
You might also want to check out a Firebase object mapper I'm working on called Firebomb (shameless plug). The Android version will be coming soon.
Finally retrieve data by using the appropriate Firebase event listeners.
I am implementing the Bing search for image searching.
I refered this link, and change my response to JSON.
It works and the result is like:
{
"d": {
"results": [{
"__metadata": {
"uri": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/Image?Query=\u0027Pepsi\u0027&$skip=0&$top=1",
"type": "ImageResult"
},
"ID": "64737694-fc53-4d68-933d-10edc214fd3a",
"Title": "Pepsi: Like Madonna, its look has been reinvented time and time again ...",
"MediaUrl": "http://tjthesportsgeek.files.wordpress.com/2012/02/pepsi.png",
"SourceUrl": "http://tjthesportsgeek.com/2012/02/14/tale-of-the-tape-coke-vs-pepsi/",
"DisplayUrl": "tjthesportsgeek.com/2012/02/14/tale-of-the-tape-coke-vs-pepsi",
"Width": "1588",
"Height": "2064",
"FileSize": "569827",
"ContentType": "image/png",
"Thumbnail": {
"__metadata": {
"type": "Bing.Thumbnail"
},
"MediaUrl": "http://ts2.mm.bing.net/th?id=OIP.M7f9b9a39639b9ca8bb6f1cba6e35d041H0&pid=15.1",
"ContentType": "image/jpg",
"Width": "369",
"Height": "480",
"FileSize": "19879"
}
},
// Next array element
]
}
}
but what i need is:
The json result with only MediaUrl and MediaUrl of Thumbnail. (As it is possible in Google Custom Search with the help of tag "field" like fields=items(link,image/thumbnailLink))
The image only with medium size. (I searched for this and applied the filter but of no use.)
Please reply with your valuable suggestions.
You can't filter output fields.
Use the parameter: ImageFilters = Size.Medium
My ref: https://onedrive.live.com/view.aspx?resid=9C9479871FBFA822!109&app=Word&authkey=!ACvyZ_MNtngQyCU