android-json

Android JSONArray looping

青春壹個敷衍的年華 提交于 2019-12-22 11:11:19
问题 This is the result I am getting from a webservice "year":["2014","2013","2012","2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998","1997","1996","1995","1994","1993","1992","1991","1990","1989","1988","1987","1986","1985","1984","1983","1982","1981","1980","1979","1978","1977","1976","1975","1974","1973","1972","1971","1970","1969","1968","1967","1966","1965","1964","1963","1962","1961","1960","1959","1958","1957","1956","1955","1954","1953","1952

How to get String response from JSONObject in Volley

只愿长相守 提交于 2019-12-22 06:30:03
问题 I have created JSONRequest by using volley, It successfully hits the service, I checked the service end, It receives the data, and send "Success" in return. The problem is that, Service returns String in output, and Volley excepts some JSON Data in output. So it executes the onError Method, instead of onResponse . Kindly guide me how to make it accept string response, or is it not possible when you are using JSONObject as request. Request<JSONObject> jsonObjectRequest = new JsonObjectRequest

Gson - Read a value with two different keys

≯℡__Kan透↙ 提交于 2019-12-22 01:33:45
问题 In my Android project I have two types of response where both response are identical except two keys . Response 1 {"fullName":"William Sherlock Scott Holmes","address":"221B Baker Street, London, England, UK","downloads":642,"rating":3,"repos":["https://link1","https://link2","https://link3"]} Response 2 {"name":"Sherlock","city":"London","downloads":642,"rating":3,"repos":["https://link1","https://link2","https://link3"]} If you see the responses only two key names are changing fullName/name

POSTing a DateTime from Android to a WCF RESTful JSON Service

点点圈 提交于 2019-12-21 02:38:08
问题 I'm trying to send a DateTime as a parameter to a method exposed over a WCF RESTful service with JSON encoding. The request looks like this: POST http://IP:PORT/LogService/json/GetLogEntriesByModule HTTP/1.1 Content-Length: 100 Content-Type: application/json Host: IP:PORT Connection: Keep-Alive User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4) Expect: 100-Continue {"maxentries":10,"upperdate":"1280703601462","lowerdate":"1277938801462","module":"Windows Service"} I tried several formats

org.json.JSONObject vs Gson library JsonObject

左心房为你撑大大i 提交于 2019-12-20 17:24:44
问题 What are differences between this two classes? If someone uses Gson library is it preferable to use com.google.json.JsonObject over org.json.JSONObject ? Could anybody list pros and cons of these 2 choices? 回答1: Many JSON implementations are available in the market and most of them are open source. Each one has specific advantages and disadvantages. Google GSON Jackson org.json etc. Google GSON click for official documents Provide simple toJson() and fromJson() methods to convert Java objects

How to get a specific json key value from post request response in Android?

时光怂恿深爱的人放手 提交于 2019-12-20 05:25:53
问题 I have following response from post request using HttpURLConnection : Post Request Response: { "LatestData": [{ "ExtraData": null, "ID": 0, "season": false, "latest": 0, "url": "http://www.awebsite.com/images/12.jpg" }] } How to get value of URL? I tried following but Android Studio keeps giving me error: String newURL = sb.getJSONObject("LatestData").getString("url"); String newURL = sb.getJSONArray("LatestData").getJSONObject(0).getString("url"); Android Studio Error: error: cannot find

Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject [closed]

一笑奈何 提交于 2019-12-18 03:00:20
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am getting this error: Error parsing data org.json.JSONException: Value This is my logcat log: 11-11 22:47:28.930: D/my(25127): method equals POST is working 11-11 22:47:28.930: D/my(25127): HTTp client is working 11-11 22:47:28.930: D/my(25127): HTTp post is working 11-11 22:47:28.930: D/my(25127): url

How do I retrieve data independently from nested JSON objects that are part of the same group in android/java? ( more clarity/details in body)

穿精又带淫゛_ 提交于 2019-12-17 21:34:43
问题 I have a pretty common scenario, but I am stuck trying to figure out how to retrieve data from certain json objects within the same json response but returning different size of items. To make it less confusing, here's my json response: { "totalResults": 5, "meetings": [ { "id": "754e6670-2376-4eb2-b5f6-ea63ca7c2669", "dateStart": "2019-11-28T15:25:36.000Z", "dateEnd": "2019-11-28T23:00:36.000Z", "visitors": [ { "visitId": "34608af6-bbe4-439c-b472-500790385f60", "firstName": "Lord", "lastName

Passing this URL to my httpget is returning null. Tried every way

可紊 提交于 2019-12-13 20:58:10
问题 I have been trying for hour every possible method on this forum but no luck. PLEASSE help I have the following server url String url = "http://namara.io/api/v0/resources/fef59c15-852f-4f4b-aaef-c9475b3d17c6/data?where=%7b%22column%22:3,%22selector%22:%22eq%22,%22value%22:%22Sercan%22%7d" Here is my code: HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(url); HttpResponse response; try { response = httpclient.execute(httpget); HttpEntity entity = response

How to parse the xml wrapping json

瘦欲@ 提交于 2019-12-13 10:57:47
问题 Can Any one tell me How to parse the following <string xmlns="http://tempuri.org/"> [{"OSID":"2","PhoneVersion":"IPHONE5","PhoneOS":"IOS","ImageName":"t_3@2x.png","ImageID":"3"},{"OSID":"2","PhoneVersion":"IPHONE5","PhoneOS":"IOS","ImageName":"t_4@2x.png","ImageID":"4"},{"OSID":"2","PhoneVersion":"IPHONE5","PhoneOS":"IOS","ImageName":"t_5@2x.png","ImageID":"5"},{"OSID":"2","PhoneVersion":"IPHONE5","PhoneOS":"IOS","ImageName":"t_6@2x.png","ImageID":"6"},{"OSID":"2","PhoneVersion":"IPHONE5",