Related
Code to call the api is as mentioned and the json response post method. error while calling json object at the line"JSONObject mJsonObj = new JSONObject(response);". Response available but error occurs as"Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate org.json.JSONObject.toString()"
String PROJECT_URL = url+ r.getString(R.string.api_Get_two);
mProgressBar.setVisibility(View.VISIBLE);
StringRequest stringRequest = new StringRequest(Request.Method.POST, PROJECT_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
pendingDataList.clear();
Log.d("JSON", response);
try {
JSONObject mJsonObj = new JSONObject(response); (Error here)
JSONArray pendingChallans = (mJsonObj).getJSONArray("Day");
if(pendingChallans.length() > 0) {
for (int i = 0; i <pendingChallans.length() ; i++) {
PendingData pending = new PendingData();
JSONObject obj = (JSONObject) pendingChallans.get(i);
pending.setRowType(obj.getString("RowType"));
pendingDataList.add(pending);
}
}else {
new Dialogs(mContext, "No Data Found .").createDialogWithMsg();
}
} catch (JSONException e) {
e.printStackTrace();
}finally {
mProgressBar.setVisibility(View.GONE);
pcdRecyclerview.setVisibility(View.VISIBLE);
myAdapter.notifyDataSetChanged();
}
}
JSON:
{
"Day": [{
"RowType": 1,
"Sl": {
"Value": "",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Particulars": {
"Value": "PEN ",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value1": {
"Value": "",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value2": {
"Value": "",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value3": {
"Value": "",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"NextLevelZoomData": "",
"NextLevelZoomType": 0
},
{
"RowType": 2,
"Sl": {
"Value": "SL.",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Particulars": {
"Value": "CUS",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value1": {
"Value": "BQty",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value2": {
"Value": "Amount",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value3": {
"Value": "Ood",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"NextLevelZoomData": "",
"NextLevelZoomType": 0
},
{
"RowType": 3,
"Sl": {
"Value": "1. ",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Particulars": {
"Value": "ETH",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value1": {
"Value": "2",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value2": {
"Value": "7",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value3": {
"Value": "165 / 165",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"NextLevelZoomData": "[{\"UnitFields\":[{\"AllowSort\":1,\"Caption\":\"Challan No.\",\"DisplayOrder\":1,\"Value\":\"2 / 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"No. of Days\",\"DisplayOrder\":2,\"Value\":\"153\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Bal. Qty\",\"DisplayOrder\":3,\"Value\":\"1.00 PCS\",\"Highlight\":0,\"Visible\":0},{\"AllowSort\":1,\"Caption\":\"Item\",\"DisplayOrder\":4,\"Value\":\"WAVE\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Rate\",\"DisplayOrder\":5,\"Value\":\"398.00\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Sale\",\"DisplayOrder\":6,\"Value\":\"L A\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Location\",\"DisplayOrder\":7,\"Value\":\" FLOOR\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Comment\",\"DisplayOrder\":8,\"Value\":\"SELECTION~\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Supplier\",\"DisplayOrder\":9,\"Value\":\"gtt\",\"Highlight\":0,\"Visible\":1}],\"Unit\":\"09\"},{\"UnitcodeFields\":[{\"AllowSort\":1,\"Caption\":\"Challan No.\",\"DisplayOrder\":1,\"Value\":\"1/ 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"No. of Days\",\"DisplayOrder\":2,\"Value\":\"139\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Bal. Qty\",\"DisplayOrder\":3,\"Value\":\"1.00 PCS\",\"Highlight\":0,\"Visible\":0},{\"AllowSort\":1,\"Caption\":\"Item\",\"DisplayOrder\":4,\"Value\":\"EMjB\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Rate\",\"DisplayOrder\":5,\"Value\":\"37,590.00\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Sale\",\"DisplayOrder\":6,\"Value\":\"L A\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Location\",\"DisplayOrder\":7,\"Value\":\"MM 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Comment\",\"DisplayOrder\":8,\"Value\":\"PERSONAL\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Supplier\",\"DisplayOrder\":9,\"Value\":\"GOUR\",\"Highlight\":0,\"Visible\":1}],\"Unit\":\"08\"}]",
"NextLevelZoomType": 2
},
{
"RowType": 3,
"Sl": {
"Value": "2. ",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Particulars": {
"Value": "SAE",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value1": {
"Value": "1",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value2": {
"Value": "30",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value3": {
"Value": "1",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"NextLevelZoomData": "[{\"UnitFields\":[{\"AllowSort\":1,\"Caption\":\"Challan No.\",\"DisplayOrder\":1,\"Value\":\"2 / 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"No. of Days\",\"DisplayOrder\":2,\"Value\":\"153\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Bal. Qty\",\"DisplayOrder\":3,\"Value\":\"1.00 PCS\",\"Highlight\":0,\"Visible\":0},{\"AllowSort\":1,\"Caption\":\"Item\",\"DisplayOrder\":4,\"Value\":\"WAVE\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Rate\",\"DisplayOrder\":5,\"Value\":\"398.00\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Sale\",\"DisplayOrder\":6,\"Value\":\"L A\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Location\",\"DisplayOrder\":7,\"Value\":\" FLOOR\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Comment\",\"DisplayOrder\":8,\"Value\":\"SELECTION~\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Supplier\",\"DisplayOrder\":9,\"Value\":\"gtt\",\"Highlight\":0,\"Visible\":1}],\"Unit\":\"09\"},{\"UnitcodeFields\":[{\"AllowSort\":1,\"Caption\":\"Challan No.\",\"DisplayOrder\":1,\"Value\":\"1/ 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"No. of Days\",\"DisplayOrder\":2,\"Value\":\"139\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Bal. Qty\",\"DisplayOrder\":3,\"Value\":\"1.00 PCS\",\"Highlight\":0,\"Visible\":0},{\"AllowSort\":1,\"Caption\":\"Item\",\"DisplayOrder\":4,\"Value\":\"EMjB\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Rate\",\"DisplayOrder\":5,\"Value\":\"37,590.00\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Sale\",\"DisplayOrder\":6,\"Value\":\"L A\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Location\",\"DisplayOrder\":7,\"Value\":\"MM 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Comment\",\"DisplayOrder\":8,\"Value\":\"PERSONAL\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Supplier\",\"DisplayOrder\":9,\"Value\":\"GOUR\",\"Highlight\":0,\"Visible\":1}],\"Unit\":\"08\"}]",
"NextLevelZoomType": 2
},
{
"RowType": 3,
"Sl": {
"Value": "3. ",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Particulars": {
"Value": " M",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value1": {
"Value": "2",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value2": {
"Value": "4455",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value3": {
"Value": "15",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"NextLevelZoomData": "[{\"UnitFields\":[{\"AllowSort\":1,\"Caption\":\"Challan No.\",\"DisplayOrder\":1,\"Value\":\"2 / 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"No. of Days\",\"DisplayOrder\":2,\"Value\":\"153\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Bal. Qty\",\"DisplayOrder\":3,\"Value\":\"1.00 PCS\",\"Highlight\":0,\"Visible\":0},{\"AllowSort\":1,\"Caption\":\"Item\",\"DisplayOrder\":4,\"Value\":\"WAVE\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Rate\",\"DisplayOrder\":5,\"Value\":\"398.00\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Sale\",\"DisplayOrder\":6,\"Value\":\"L A\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Location\",\"DisplayOrder\":7,\"Value\":\" FLOOR\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Comment\",\"DisplayOrder\":8,\"Value\":\"SELECTION~\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Supplier\",\"DisplayOrder\":9,\"Value\":\"gtt\",\"Highlight\":0,\"Visible\":1}],\"Unit\":\"09\"},{\"UnitcodeFields\":[{\"AllowSort\":1,\"Caption\":\"Challan No.\",\"DisplayOrder\":1,\"Value\":\"1/ 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"No. of Days\",\"DisplayOrder\":2,\"Value\":\"139\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Bal. Qty\",\"DisplayOrder\":3,\"Value\":\"1.00 PCS\",\"Highlight\":0,\"Visible\":0},{\"AllowSort\":1,\"Caption\":\"Item\",\"DisplayOrder\":4,\"Value\":\"EMjB\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Rate\",\"DisplayOrder\":5,\"Value\":\"37,590.00\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Sale\",\"DisplayOrder\":6,\"Value\":\"L A\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Location\",\"DisplayOrder\":7,\"Value\":\"MM 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Comment\",\"DisplayOrder\":8,\"Value\":\"PERSONAL\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Supplier\",\"DisplayOrder\":9,\"Value\":\"GOUR\",\"Highlight\":0,\"Visible\":1}],\"Unit\":\"08\"}]",
"NextLevelZoomType": 2
},
{
"RowType": 3,
"Sl": {
"Value": "4. ",
"isBold": 1,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Particulars": {
"Value": " DESIGNS",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value1": {
"Value": "1",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value2": {
"Value": "2000",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"Value3": {
"Value": "14",
"isBold": 0,
"isItalics": 0,
"Levels": 1,
"Align": 1
},
"NextLevelZoomData": "[{\"UnitFields\":[{\"AllowSort\":1,\"Caption\":\"Challan No.\",\"DisplayOrder\":1,\"Value\":\"00/ 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"No. of Days\",\"DisplayOrder\":2,\"Value\":\"146\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Bal. Qty\",\"DisplayOrder\":3,\"Value\":\"1.00 PCS\",\"Highlight\":0,\"Visible\":0},{\"AllowSort\":1,\"Caption\":\"Item\",\"DisplayOrder\":4,\"Value\":\"EMB\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Rate\",\"DisplayOrder\":5,\"Value\":\"2000\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Sale\",\"DisplayOrder\":6,\"Value\":\"L A\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Location\",\"DisplayOrder\":7,\"Value\":\"MM 1\",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Comment\",\"DisplayOrder\":8,\"Value\":\"ONE \",\"Highlight\":0,\"Visible\":1},{\"AllowSort\":1,\"Caption\":\"Supplier\",\"DisplayOrder\":9,\"Value\":\"FAIR \",\"Highlight\":0,\"Visible\":1}]}]",
"NextLevelZoomType": 2
}
],
"Status": 1,
"Msg": "Success"
}
```[Screenshot attached on debugging ][1]
[1]: https://i.stack.imgur.com/WrCOb.png
{
"totalHits": 500,
"hits": [
{
"largeImageURL": "https://pixabay.com/get/52e3d6414352af14f6da8c7dda79367b153fdee254506c4870277bd3934ec45ebf_1280.jpg",
"webformatHeight": 424,
"webformatWidth": 640,
"likes": 11,
"imageWidth": 4456,
"id": 4332903,
"user_id": 1151065,
"views": 697,
"comments": 14,
"pageURL": "https://pixabay.com/photos/evangelion-mech-unit-02-robot-4332903/",
"imageHeight": 2958,
"webformatURL": "https://pixabay.com/get/52e3d6414352af14f6da8c7dda79367b153fdee254506c4870277bd3934ec45ebf_640.jpg",
"type": "photo",
"previewHeight": 99,
"tags": "evangelion mech unit 02, robot, fighter",
"downloads": 311,
"user": "vinsky2002",
"favorites": 0,
"imageSize": 878944,
"previewWidth": 150,
"userImageURL": "https://cdn.pixabay.com/user/2019/05/15/02-40-06-911_250x250.png",
"previewURL": "https://cdn.pixabay.com/photo/2019/07/12/13/44/evangelion-mech-unit-02-4332903_150.jpg"
},
{
"largeImageURL": "https://pixabay.com/get/55e7d54b4d51a514f6da8c7dda79367b153fdee254506c4870277bd3934ec45ebf_1280.jpg",
"webformatHeight": 359,
"webformatWidth": 640,
"likes": 18,
"imageWidth": 3863,
"id": 3708739,
"user_id": 10248012,
"views": 2696,
"comments": 2,
"pageURL": "https://pixabay.com/photos/sky-dark-night-moon-moonlight-3708739/",
"imageHeight": 2170,
"webformatURL": "https://pixabay.com/get/55e7d54b4d51a514f6da8c7dda79367b153fdee254506c4870277bd3934ec45ebf_640.jpg",
"type": "photo",
"previewHeight": 84,
"tags": "sky, dark, night",
"downloads": 1036,
"user": "Sritam_kumar_Sethy",
"favorites": 25,
"imageSize": 2027189,
"previewWidth": 150,
"userImageURL": "https://cdn.pixabay.com/user/2019/09/28/19-27-53-806_250x250.jpeg",
"previewURL": "https://cdn.pixabay.com/photo/2018/09/28/08/37/sky-3708739_150.jpg"
},
{
"largeImageURL": "https://pixabay.com/get/57e2dc4a4c5aaf14f6da8c7dda79367b153fdee254506c4870277bd3934ec45ebf_1280.jpg",
"webformatHeight": 360,
"webformatWidth": 640,
"likes": 14,
"imageWidth": 4608,
"id": 1299683,
"user_id": 1151065,
"views": 2932,
"comments": 3,
"pageURL": "https://pixabay.com/photos/panda-z-panda-toy-children-child-1299683/",
"imageHeight": 2592,
"webformatURL": "https://pixabay.com/get/57e2dc4a4c5aaf14f6da8c7dda79367b153fdee254506c4870277bd3934ec45ebf_640.jpg",
"type": "photo",
"previewHeight": 84,
"tags": "panda-z, panda, toy",
"downloads": 1067,
"user": "vinsky2002",
"favorites": 7,
"imageSize": 1745060,
"previewWidth": 150,
"userImageURL": "https://cdn.pixabay.com/user/2019/05/15/02-40-06-911_250x250.png",
"previewURL": "https://cdn.pixabay.com/photo/2016/04/01/09/56/panda-z-1299683_150.jpg"
},
],
"total": 588
}
The API I'm fetching returns json value like this. I wrote the following code to extract the data, it works if I code it like this and the widget builds, but with this error before the widget loads
Future getJsonData() async{
var response;
for(int i=1; i<=5; i++){
response = await http.get(
Uri.encodeFull(widget.api+i.toString()),
headers: {"Accept": "application/json"}
);
setState(() {
var toJsonData = json.decode(response.body);
item.addAll(toJsonData['hits']);
});
}
print(response.body);
return item;
}
error image
But when I use FutureBuilder method, it fails to create the widget. It would be helpful if someone can tell a possibly working FutureBuilder method for this json data.
{
"count": 7,
"next": null,
"previous": null,
"results": [
{
"get_Infographs": [
{
"viewCount": 17,
"likecount": 1,
"unlikeCount": 1,
"shareCount": 0,
"i_id": 532,
"p_id": 532,
"name": "Yoga happiness educational s",
"description": "Yoga happiness educational spiritual journey lifestyle health ",
"c_id": 1,
"status_id": 1,
"source_id": 316,
"date_created": null,
"parentinfograph": "Language english grammar apo",
"internal_url": "http://167.99.86.81:8000/media/DQ532.png",
"external_url": "http://yogadork.com/wp-content/uploads/2015/01/2015-yoga-resolutions-infographic.png",
"mt_id": 3,
"mtcode": "Education",
"topics": [
{
"topic_code": "#EDUCATION"
},
{
"topic_code": "#HEALTH"
}
],
"geoPolitical": [
{
"gp_code": "Default / All GPIDs"
}
],
"entity": [],
"customMetaTags": [
{
"metatag": "#"
}
]
}
]
}
]
}
Read customMetaTags it as ArrayList and then you can pass it using bundle
bundle.putSerializable("some_string", arrayList)
My Json Value is
{"candidateName":"Check","success":true,"candidateWorkExperience":"[{\"candidateWorkExperienceId\":7486,\"candidateBiographyRef\":{\"primaryKey\":98567,\"percent\":0.0,\"specialization\":0,\"rating\":0,\"description\":\"Check\",\"properties\":{},\"secondaryKey\":0,\"start\":0,\"limit\":0,\"noOfStud\":0,\"typingTest\":false,\"isPostGrad\":false},\"designation\":\"Check\",\"company\":\"Check\",\"startDate\":\"Jan 1, 2012\",\"endDate\":\"Jan 1, 2014\",\"workTypeMasterRef\":{\"primaryKey\":2,\"percent\":0.0,\"specialization\":0,\"rating\":0,\"description\":\"Permanent\",\"properties\":{},\"secondaryKey\":0,\"start\":0,\"limit\":0,\"noOfStud\":0,\"typingTest\":false,\"isPostGrad\":false},\"achivements\":\"Check\",\"candidateRecordStatus\":\"EXISTING\",\"currentCompany\":\"false\"}]"}
I am trying to pass the same by
JSONArray jarray = jsono.getJSONArray("candidateWorkExperience");
But I am getting org.json.JSON.typeMismatch exception.
Can any one suggest how to load the json data into the array.
Your problem is that you put "[]" which js is interpreting as a string not an array.
The arrays are enclosed by [] with no ".
Try the next json and let me know if this fix your problem:
{
"candidateName": "Check",
"success": true,
"candidateWorkExperience": [
{
"candidateWorkExperienceId": 7486,
"candidateBiographyRef": {
"primaryKey": 98567,
"percent": 0.0,
"specialization": 0,
"rating": 0,
"description": "Check",
"properties": {
},
"secondaryKey": 0,
"start": 0,
"limit": 0,
"noOfStud": 0,
"typingTest": false,
"isPostGrad": false
},
"designation": "Check",
"company": "Check",
"startDate": "Jan1, 2012",
"endDate": "Jan1, 2014",
"workTypeMasterRef": {
"primaryKey": 2,
"percent": 0.0,
"specialization": 0,
"rating": 0,
"description": "Permanent",
"properties": {
},
"secondaryKey": 0,
"start": 0,
"limit": 0,
"noOfStud": 0,
"typingTest": false,
"isPostGrad": false
},
"achivements": "Check",
"candidateRecordStatus": "EXISTING",
"currentCompany": "false"
}
]
}
Your JSON is not correct, your "candidateWorkExperience" parameter is not a JSONArray but a JSONString.
Paste your JSON here
And you will see how you JSON is parsed.
Cheers !
I need to play Vimeo viodes in my app having only video id. For example 83342420.
How can I get vimeo video url? Or is there any other way to play video in android?
I tried WebView solution but it doesn't suit.
I also tried the urls like http://vimeo.com/moogaloop/play/clip:7926539/5cd4f7989ee0cb5018c131260aa1fc8c/1309860388/ but I'm getting 404 Not found.
Maybe I need some kind of api key or token?
Thanks.
Ok. For getting direct url for Vimeo video just need to send GET Request to url:
old url - http://player.vimeo.com/v2/video/<video_id>/config
**UPD**: new url - http://player.vimeo.com/video/<video_id>/config
In result you will get such response:
{
"cdn_url": "http://f.vimeocdn.com",
"view": 1,
"request": {
"files": {
"h264": {
"mobile": {
"profile": 116,
"origin": "ns3.pdl",
"url": "http://pdl.vimeocdn.com/84730/904/216566897.mp4?token2=1397407519_8b323701fa08b3531612d6160be9cc5e&aksessionid=01788ff54890a9b2",
"height": 270,
"width": 480,
"id": 216566897,
"bitrate": 547,
"availability": 60
},
"hd": {
"profile": 113,
"origin": "ns3.pdl",
"url": "http://pdl.vimeocdn.com/87179/143/216566895.mp4?token2=1397407519_1d0ef28841fb628c423f9dbeb93168d4&aksessionid=2a0b480300c82ef7",
"height": 720,
"width": 1280,
"id": 216566895,
"bitrate": 3142,
"availability": 60
},
"sd": {
"profile": 112,
"origin": "ns3.pdl",
"url": "http://pdl.vimeocdn.com/57248/568/216566886.mp4?token2=1397407519_395f6cf4e80b98826424e21c8de508d1&aksessionid=598e59776ed0979a",
"height": 360,
"width": 640,
"id": 216566886,
"bitrate": 1198,
"availability": 60
}
},
"hls": {
"all": "http://av20.hls.vimeocdn.com/i/,57248/568/216566886,87179/143/216566895,84730/904/216566897,.mp4.csmil/master.m3u8?primaryToken=1397407519_93cf5d54b3482e3a1e716cf28b9550a7",
"hd": "http://av20.hls.vimeocdn.com/i/,87179/143/216566895,.mp4.csmil/master.m3u8?primaryToken=1397407519_a84194ace821175f0ee0ff9ab8d9241f"
},
"codecs": [
"h264"
]
},
"ga_account": "UA-76641-35",
"timestamp": 1397406594,
"expires": 925,
"prefix": "/v2",
"session": "d85291b3aa5b3e5fbf3ea82d81d7d5e849aa50e5",
"cookie": {
"scaling": 1,
"volume": 1.0,
"hd": null,
"captions": null
},
"cookie_domain": ".vimeo.com",
"referrer": null,
"conviva_account": "c3.Vimeo",
"flags": {
"login": 1,
"preload_video": 1,
"plays": 1,
"partials": 1,
"conviva": 1
},
"build": {
"player": "a30ff35f",
"js": "2.4.7"
},
"urls": {
"zeroclip_swf": "http://f.vimeocdn.com/p/external/zeroclipboard/ZeroClipboard.swf",
"js": "http://f.vimeocdn.com/p/2.4.7/js/player.js",
"proxy": "https://f.vimeocdn.com/p/2.4.7/proxy.html",
"conviva": "http://livepassdl.conviva.com/ver/2.72.0.13589/LivePass.js",
"flideo": "http://f.vimeocdn.com/p/flash/flideo/1.0.3b10/flideo.swf",
"canvas_js": "http://f.vimeocdn.com/p/2.4.7/js/player.canvas.js",
"moog": "http://f.vimeocdn.com/p/flash/moogaloop/6.0.9/moogaloop.swf?clip_id=83342420",
"conviva_service": "http://livepass.conviva.com",
"moog_js": "http://f.vimeocdn.com/p/2.4.7/js/moogaloop.js",
"zeroclip_js": "http://f.vimeocdn.com/p/external/zeroclipboard/ZeroClipboard-patch.js",
"css": "http://f.vimeocdn.com/p/2.4.7/css/player.css"
},
"signature": "09c6bc41e6a7d343748ed3e00420a108"
},
"player_url": "player.vimeo.com",
"video": {
"allow_hd": 1,
"height": 720,
"owner": {
"account_type": "pro",
"name": "Sabian",
"img": "http://i.vimeocdn.com/portrait/2511583_75x75.jpg",
"url": "http://vimeo.com/sabian",
"img_2x": "http://i.vimeocdn.com/portrait/2511583_150x150.jpg",
"id": 8487062
},
"thumbs": {
"1280": "http://i.vimeocdn.com/video/459788805_1280.jpg",
"960": "http://i.vimeocdn.com/video/459788805_960.jpg",
"640": "http://i.vimeocdn.com/video/459788805_640.jpg"
},
"duration": 25,
"id": 83342420,
"hd": 1,
"embed_code": "<iframe src=\"//player.vimeo.com/video/83342420\" width=\"500\" height=\"281\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>",
"default_to_hd": 0,
"title": "Mike Portnoy",
"url": "https://vimeo.com/83342420",
"privacy": "anybody",
"share_url": "http://vimeo.com/83342420",
"width": 1280,
"embed_permission": "public",
"fps": 24.0
},
"build": {
"player": "a30ff35f",
"rpc": "dev"
},
"embed": {
"player_id": null,
"outro": "videos",
"api": 2,
"context": "embed.main",
"time": 0,
"color": "00adef",
"settings": {
"fullscreen": 1,
"byline_badge": {
"url": "http://vimeo.com/sabian",
"type": "pro"
},
"byline": 1,
"like": 1,
"playbar": 1,
"title": 1,
"color": 0,
"branding": 1,
"share": 1,
"scaling": 1,
"logo": 1,
"info_on_pause": 0,
"watch_later": 1,
"portrait": 1,
"embed": 1,
"badge": 0,
"volume": 1
},
"on_site": 0,
"loop": 0,
"autoplay": 0
},
"vimeo_url": "vimeo.com",
"user": {
"liked": 0,
"account_type": "basic",
"logged_in": 1,
"owner": 0,
"watch_later": 0,
"id": 26896968,
"mod": false
}
}
Vimeo does not offer support for any videos play urls. Vimeo only offers 2 methods for playing videos on mobile.
Embeddable videos work in many Android web views.
PRO members have access to direct video file links (including HLS) and can use these in their own mobile apps.
use this url - http://player.vimeo.com/video/video_id/config with GET method, and pass your video_id, you will get the below result. this is latest response is coming from Vimeo, because the change response.
{
"cdn_url": "https://f.vimeocdn.com",
"vimeo_api_url": "api.vimeo.com",
"request": {
"files": {
"dash": {
"separate_av": true,
"streams": [
{
"profile": 164,
"quality": "360p",
"id": 1047687609,
"fps": 30
},
{
"profile": 175,
"quality": "1080p",
"id": 1047687611,
"fps": 30
},
{
"profile": 165,
"quality": "540p",
"id": 1047687607,
"fps": 30
},
{
"profile": 174,
"quality": "720p",
"id": 1047687604,
"fps": 30
}
],
"cdns": {
"akfire_interconnect_quic": {
"url": "https://112skyfiregce-vimeo.akamaized.net/exp=1531572843~acl=%2F279620511%2F%2A~hmac=fc67765d21d06ae32cd69b0fa7a9f229ba5c492a6ea14d14cfee32fce9afb1a2/279620511/sep/video/1047687609,1047687611,1047687607,1047687604/master.json?base64_init=1",
"origin": "gcs"
},
"fastly_skyfire": {
"url": "https://skyfire.vimeocdn.com/1531572843-0xb2b233940673f62145704b412d1469ea2f179a4c/279620511/sep/video/1047687609,1047687611,1047687607,1047687604/master.json?base64_init=1",
"origin": "gcs"
}
},
"default_cdn": "akfire_interconnect_quic"
},
"hls": {
"separate_av": false,
"default_cdn": "akfire_interconnect_quic",
"cdns": {
"akfire_interconnect_quic": {
"url": "https://112skyfiregce-vimeo.akamaized.net/exp=1531572843~acl=%2F279620511%2F%2A~hmac=fc67765d21d06ae32cd69b0fa7a9f229ba5c492a6ea14d14cfee32fce9afb1a2/279620511/video/1047687609,1047687611,1047687607,1047687604/master.m3u8",
"origin": "gcs"
},
"fastly_skyfire": {
"url": "https://skyfire.vimeocdn.com/1531572843-0xb2b233940673f62145704b412d1469ea2f179a4c/279620511/video/1047687609,1047687611,1047687607,1047687604/master.m3u8",
"origin": "gcs"
}
}
},
"progressive": [
{
"profile": 175,
"width": 1920,
"mime": "video/mp4",
"fps": 30,
"url": "https://gcs-vimeo.akamaized.net/exp=1531572843~acl=%2A%2F1047687611.mp4%2A~hmac=90eacf4c4956f322393ac1b5e4d0df91694c5e5af36eabccd2a28780e4364148/vimeo-prod-skyfire-std-us/01/924/11/279620511/1047687611.mp4",
"cdn": "akamai_interconnect",
"quality": "1080p",
"id": 1047687611,
"origin": "gcs",
"height": 1080
},
{
"profile": 164,
"width": 640,
"mime": "video/mp4",
"fps": 30,
"url": "https://gcs-vimeo.akamaized.net/exp=1531572843~acl=%2A%2F1047687609.mp4%2A~hmac=4c90608f99044633906efb33f04e314569cd865266529b96977ee7eeecce4f80/vimeo-prod-skyfire-std-us/01/924/11/279620511/1047687609.mp4",
"cdn": "akamai_interconnect",
"quality": "360p",
"id": 1047687609,
"origin": "gcs",
"height": 360
},
{
"profile": 165,
"width": 960,
"mime": "video/mp4",
"fps": 30,
"url": "https://gcs-vimeo.akamaized.net/exp=1531572843~acl=%2A%2F1047687607.mp4%2A~hmac=a0f28428ec2da33b5501936f32a3bc17aee0446dfbb5f0597c5b51f743cebc65/vimeo-prod-skyfire-std-us/01/924/11/279620511/1047687607.mp4",
"cdn": "akamai_interconnect",
"quality": "540p",
"id": 1047687607,
"origin": "gcs",
"height": 540
},
{
"profile": 174,
"width": 1280,
"mime": "video/mp4",
"fps": 30,
"url": "https://gcs-vimeo.akamaized.net/exp=1531572843~acl=%2A%2F1047687604.mp4%2A~hmac=6a3da45344051eb54196967bebebbd34841f09c049ca377b7f664786f24dfb95/vimeo-prod-skyfire-std-us/01/924/11/279620511/1047687604.mp4",
"cdn": "akamai_interconnect",
"quality": "720p",
"id": 1047687604,
"origin": "gcs",
"height": 720
}
]
},
"lang": "en",
"sentry": {
"url": "https://9e9ab33f1870463393a4a1e85a1280c2#sentry.cloud.vimeo.com/2",
"enabled": false,
"debug_enabled": true,
"debug_intent": 0
},
"ab_tests": {},
"referrer": null,
"cookie_domain": ".vimeo.com",
"timestamp": 1531568943,
"gc_debug": {
"bucket": "vimeo-player-debug"
},
"expires": 3600,
"currency": "USD",
"session": "d2a0f4ba2c4a97b7e59e349e54ee5e4d212a78b01531568943",
"cookie": {
"scaling": 1,
"volume": 1,
"quality": null,
"hd": 0,
"captions": null
},
"build": {
"player": "",
"js": "2.75.6"
},
"urls": {
"zeroclip_swf": "https://f.vimeocdn.com/p/external/zeroclipboard/ZeroClipboard.swf",
"fresnel": "https://fresnel.vimeocdn.com/add/player-stats",
"js": "https://f.vimeocdn.com/p/2.75.6/js/player.js",
"proxy": "https://player.vimeo.com/static/proxy.html",
"chromeless_css": "https://f.vimeocdn.com/p/2.75.6/css/chromeless.css",
"flideo": "https://f.vimeocdn.com/p/flash/flideo/1.0.6/flideo.swf",
"moog": "https://f.vimeocdn.com/p/flash/moogaloop/6.4.5/moogaloop.swf?clip_id=279620511",
"three_js": "https://f.vimeocdn.com/p/external/three.rvimeo.min.js",
"mux_url": "https://f.vimeocdn.com/p/external/mux.js",
"vuid_js": "https://f.vimeocdn.com/js_opt/modules/utils/vuid.min.js",
"chromeless_js": "https://f.vimeocdn.com/p/2.75.6/js/chromeless.js",
"moog_js": "https://f.vimeocdn.com/p/2.75.6/js/moogaloop.js",
"zeroclip_js": "https://f.vimeocdn.com/p/external/zeroclipboard/ZeroClipboard-patch.js",
"css": "https://f.vimeocdn.com/p/2.75.6/css/player.css"
},
"signature": "8544b7e2ca11afdca19cef76f57fed72",
"flags": {
"dnt": 0,
"preload_video": "metadata_on_hover",
"plays": 1,
"webp": 0,
"flash_hls": 1,
"log_to_es": 0,
"partials": 1,
"autohide_controls": 0
},
"country": "IN"
},
"player_url": "player.vimeo.com",
"video": {
"version": {
"current": null,
"available": [
{
"is_current": 1,
"id": 20743507,
"file_id": 1047687416
}
]
},
"height": 1080,
"duration": 543,
"thumbs": {
"640": "https://i.vimeocdn.com/video/712935666_640.jpg",
"960": "https://i.vimeocdn.com/video/712935666_960.jpg",
"1280": "https://i.vimeocdn.com/video/712935666_1280.jpg",
"base": "https://i.vimeocdn.com/video/712935666"
},
"owner": {
"account_type": "pro",
"name": "You Are a CEO",
"img": "https://i.vimeocdn.com/portrait/26028985_60x60.jpg",
"url": "https://vimeo.com/user19222589",
"img_2x": "https://i.vimeocdn.com/portrait/26028985_120x120.jpg",
"id": 19222589
},
"file_codecs": {
"hevc": {
"hdr": [],
"sdr": []
},
"avc": [
1047687611,
1047687609,
1047687607,
1047687604
]
},
"id": 279620511,
"embed_code": "<iframe src=\"https://player.vimeo.com/video/279620511\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen></iframe>",
"title": "DRAFT- MINTSHOW TO UPLIFT",
"share_url": "https://vimeo.com/279620511",
"width": 1920,
"embed_permission": "public",
"fps": 30,
"spatial": 0,
"live_event": null,
"allow_hd": 1,
"hd": 1,
"lang": null,
"default_to_hd": 0,
"url": null,
"privacy": "unlisted",
"unlisted_hash": "1795b097a5"
},
"user": {
"vimeo_api_interaction_tokens": null,
"liked": 0,
"account_type": "none",
"vimeo_api_client_token": null,
"progress": 0,
"owner": 0,
"watch_later": 0,
"logged_in": 0,
"id": 0,
"mod": 0
},
"embed": {
"autopause": 1,
"playsinline": 1,
"settings": {
"fullscreen": 1,
"byline": 1,
"like": 1,
"playbar": 1,
"title": 1,
"color": 0,
"branding": 1,
"watch_later": 1,
"share": 0,
"scaling": 1,
"spatial_compass": 1,
"collections": 0,
"info_on_pause": 0,
"portrait": 1,
"logo": 1,
"embed": 1,
"badge": 0,
"spatial_label": 1,
"speed": 0,
"volume": 1
},
"color": "00adef",
"on_site": 0,
"app_id": "",
"muted": 0,
"dnt": 0,
"player_id": "",
"api": 3,
"editor": false,
"context": "embed.main",
"time": 0,
"outro": "videos",
"log_plays": 1,
"quality": null,
"transparent": 1,
"loop": 0,
"autoplay": 0
},
"view": 1,
"vimeo_url": "vimeo.com"
}
Going off of what Andrew F had commented, I wrote this simple Javascript to handle this process:
function loadVimeoVideo(id) {
'use strict';
var req, json, url;
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
req = new XMLHttpRequest();
} else { // code for IE6, IE5
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = function () {
if (req.readyState === 4 && req.status === 200) {
json = JSON.parse(req.responseText);
url = json.request.files.h264.sd.url;
document.getElementById(id).getElementsByTagName("source")[0].setAttribute("src",url);
}
};
req.open("GET", ("https://player.vimeo.com/video/").concat(id, "/config"), true);
req.send();
}
The setup in Html looks like this:
<video id="YOURVIMEOIDHERE" controls loop muted preload="auto" autoplay="false" onloadeddata="loadVimeoVideo('YOURVIMEOIDHERE')">
<source src="" type="video/mp4" />
Your browser does not support the video tag, which was introduced in html5.
</video>
Edit: I'm just going to say it, remember to replace YOURVIMEOIDHERE with your Vimeo video's id.
To Play Vimeo Video from the iframe url, use that code. It's working fine.
Use layout with Web view and frame Layout
Create a custom WebViewClient for Both ChromeClient and WebViewClient
and Play video either using Loadurl or LoadBaseUrl .
{
enter code here
webView = (WebView) findViewById(R.id.web_details);
mWebViewClient = new myWebViewClient();
webView.setWebViewClient(mWebViewClient);
mWebChromeClient = new myWebChromeClient();
webView.setWebChromeClient(mWebChromeClient);
WebSetting settings = webView.getSetting();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setMinimumFontSize(10);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
webView.setVerticalScrollBarEnabled(false);
vUrl = changedHeaderHtml(getIntent().getStringExtra("videoUrl"));
webView.loadDataWithBaseURL(null, vUrl, "text/html", "UTF-8", null);
}
public static String changedHeaderHtml(String strUrl) {
return "<head><meta name=\"viewport\" content=\"width=device-width, user-scalable=yes\" /></head>" + strUrl + "</body></html>";
}
public boolean inCustomView() {
return (mCustomView != null);
}
public void hideCustomView() {
mWebChromeClient.onHideCustomView();
}
#Override
protected void onPause() {
super.onPause(); //To change body of overridden methods use File | Settings | File Templates.
webView.onPause();
}
#Override
protected void onResume() {
super.onResume(); //To change body of overridden methods use File | Settings | File Templates.
webView.onResume();
}
#Override
protected void onStop() {
super.onStop(); //To change body of overridden methods use File | Settings | File Templates.
if (inCustomView()) {
hideCustomView();
}
}
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (inCustomView()) {
hideCustomView();
return true;
}
if ((mCustomView == null) && webView.canGoBack()) {
webView.goBack();
return true;
}
}
return super.onKeyDown(keyCode, event);
}
class myWebChromeClient extends WebChromeClient {
private Bitmap mDefaultVideoPoster;
private View mVideoProgressView;
#Override
public void onShowCustomView(View view, int requestedOrientation,CustomViewCallback callback) {
onShowCustomView(view, callback); //To change body of overridden methods use File | Settings | File Templates.
}
#Override
public void onShowCustomView(View view,CustomViewCallback callback) {
// if a view already exists then immediately terminate the new one
if (mCustomView != null) {
callback.onCustomViewHidden();
return;
}
mCustomView = view;
webView.setVisibility(View.GONE);
customViewContainer.setVisibility(View.VISIBLE);
customViewContainer.addView(view);
customViewCallback = callback;
}
#Override
public View getVideoLoadingProgressView() {
if (mVideoProgressView == null) {
LayoutInflater inflater = LayoutInflater.from(WebMainActivity.this);
mVideoProgressView = inflater.inflate(R.layout.video_progress, null);
}
return mVideoProgressView;
}
#Override
public void onHideCustomView() {
super.onHideCustomView(); //To change body of overridden methods use File | Settings | File Templates.
if (mCustomView == null)
return;
webView.setVisibility(View.VISIBLE);
customViewContainer.setVisibility(View.GONE);
// Hide the custom view.
mCustomView.setVisibility(View.GONE);
// Remove the custom view from its container.
customViewContainer.removeView(mCustomView);
customViewCallback.onCustomViewHidden();
mCustomView = null;
}
}
class myWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
url =vUrl;
return super.shouldOverrideUrlLoading(view, url);
}
}
}