jsonarray

parsing data from JSON using Volley in Android

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I tried parsing JSON data from " https://api.instagram.com/v1/media/popular?client_id= " + clientId; or any other url, in a tons of different ways! Used couple of JSONParsers, tutorials, readers .. everything, but still can't to get anything from those urls. Now I am using Volley library and still can't get it to work, here is my code and everything you need, if anyone has any ideas , please share them. public void LoadPictures() { mRequestQueue = Volley.newRequestQueue(this); mRequestQueue.add(new JsonObjectRequest(urlInst, null, new

fetch friends list from facebook sdk 4.0.1 in android with graph api 2.2

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Code i used for fetching the list after doing some search is below GraphRequestBatch batch = new GraphRequestBatch( GraphRequest.newMyFriendsRequest( accessToken, new GraphRequest.GraphJSONArrayCallback() { @Override public void onCompleted( JSONArray jsonArray, GraphResponse response) { // Application code for users friends System.out.println("getFriendsData onCompleted : jsonArray " + jsonArray); System.out.println("getFriendsData onCompleted : response " + response); try { JSONObject jsonObject = response.getJSONObject(); System.out

Android: JSON parse: null object reference when attempting to parse JSON into a ListView

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This app is supposed to parse some JSON data (hard coded for now) from the Google Books API, and pass an ArrayList of Books to the adapter that will display it on a ListView. The problem I have is that the JSON parse is returning null instead of the parsed data. public class MainActivity extends AppCompatActivity implements View.OnClickListener { ProgressBar pBar; List<MyTask> tasks; ArrayList<Book> bookList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity

Android google maps API 2 got JSONException:org.json.JSONException: Index 0 out of range [0..0) at org.json.JSONArray.get(JSONArray.java:263)

匿名 (未验证) 提交于 2019-12-03 02:43:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am drawing route between 18 locations to draw the google map v2.When i start fetching routes it draws route but some times it is not drawing route and it gives JSONException :org.json.JSONException: Index 0 out of range [0..0) at org.json.JSONArray.get(JSONArray.java:263) and also it gives "error_message" : "You have exceeded your daily request quota for this API." "routes" : [] "status" : "OVER_QUERY_LIMIT" public class JSONParser { static InputStream is = null; static JSONObject jObj = null; static String json = ""; // constructor public

“A JSONArray text must start with &#039;[&#039; at character 1 of null”

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Just wondering what that error could mean? I get it from the following code.. try{ JSONArray jArray = new JSONArray(result); for(int i=0;i<jArray.length();i++){ JSONObject json_data = jArray.getJSONObject(i); Log.i("log_tag","id: "+json_data.getInt("id")+ ", name: "+json_data.getString("name")+ ", sex: "+json_data.getInt("sex")+ ", birthyear: "+json_data.getInt("birthyear") ); } } }catch(JSONException e){ Log.e("log_tag", "Error parsing data "+e.toString()); } 回答1: Result is null, apparently. Or it simply does not start with [ . Print it out

a jsonarray text must start with &#039;[&#039; at character 1 of {my returned value}

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm very new to RESTFull WCF Services and even newer to calling them from an Android app. Here's my WCF service: [ServiceContract] public interface IPeople { [OperationContract] void DoWork(); [WebGet(UriTemplate = "/GetPeople", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] [OperationContract] string GetPeople(); } The implementation of the interface: public string GetPeople() { PeoplesEntities qe = new PeoplesEntities(); var result = from q in qe.tPeople

Send array from android and receive at PhP server using Volley

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hi I want to send an array of String value to PhP server and PhP decode and store them in PhP variable Here is my code at android studio private void getEventDetailRespond(RequestQueue requestQueue) { JSONObject params = new JSONObject(); try { for (int i=0; i <eventIDBeacon.size();i++){ params.put(Config.EVENT_ID, eventIDBeacon.get(i)); } } catch (JSONException e) { e.printStackTrace(); } //Creating a JSONObject request JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST,Config.DATA_URL,params.toString(), new

how to check if a JSONArray is empty in java?

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on an android app that get json content of a webservice called "WebUntis". The Json content i am getting looks like: {"jsonrpc":"2.0","id":"req-002", "result":[ {"id":125043,"date":20110117,"startTime":800,"endTime":850, "kl":[{"id":71}], "te":[{"id":23}], "su":[{"id":13}], "ro":[{"id":1}]}, {"id":125127,"date":20110117,"startTime":1055,"endTime":1145, "kl":[{"id":71}], "te":[{"id":41}], "su":[{"id":19}], "ro":[{"id":31}]}, ...]} As you can see in the result-array there are also other arrays like "kl", "su" and "ro" I am getting

How to check JSON in response body with mockMvc

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is my method inside my controller which is annotated by @Controller @RequestMapping(value = "/getServerAlertFilters/{serverName}/", produces = "application/json; charset=utf-8") @ResponseBody public JSONObject getServerAlertFilters(@PathVariable String serverName) { JSONObject json = new JSONObject(); List<FilterVO> filteredAlerts = alertFilterService.getAlertFilters(serverName, ""); JSONArray jsonArray = new JSONArray(); jsonArray.addAll(filteredAlerts); json.put(SelfServiceConstants.DATA, jsonArray); return json; } I am expecting {

Java Convert this string to JSONArray [closed]

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting the following String response from a server: {"fid":"1272","uri":"http://someurl/services/file/1272"} I need to convert it into a JSONArray . Any help? By the way, I tried this and it does not work: String response=getResponseFromServer(); JSONArray array = new JSONArray(response); I get the error: org.json.JSONException: Value {"fid":"1272","uri":"http://someurl/services/file/1272"} of type org.json.JSONObject cannot be converted to JSONArray 回答1: If you're talking about using the JSON in java library, then since your input