jsonobject

浅谈JSONObject解析JSON数据

一笑奈何 提交于 2019-12-03 14:08:22
原文地址:https://segmentfault.com/a/1190000015363286?utm_source=tag-newest 根据一段天气API来说一下JSONObject如何解析json数据,尽管现在在开发中使用Gson等,对于像我这样初次使用Java做开发的小白,说一下也是好的。 JSON数据 选取这段json数据是因为这段数据还是比较复杂的,能涵盖要说的关键点 { "data": { "city": "深圳", "temphigh": "25", "templow": "19", "updatetime": "2017-11-04 13:23:00", "tempnow": "24", "sendibletemp": "27", "winddirect": "东北风", "windpower": "2级", "humidity": "42", "sunrise": "06:29", "sunset": "17:45", "weather": "多云", "week": "星期六", "nl": null, "date": "2017-11-04", "index": [ { "name": "化妆指数", "level": "控油", "msg": "建议用露质面霜打底,水质无油粉底霜,透明粉饼,粉质胭脂。" }, { "name": "感冒指数",

Post Json object data to get Json array response using volley in android

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 12:29:59
I need to post JSONObject (using Volley ) to a web-service which is returning the response in JSONArray format. Here is what I have tried so far. final JSONObject requestJsonObject = new JSONObject(); requestJsonObject.put("username", userName); requestJsonObject.put("password", password); JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST, ServiceUrls.LOGIN_URL, requestJsonObject, loginResponseListener, loginErrorListener); private Listener<JSONObject> loginResponseListener = new Listener<JSONObject>() { @Override public void onResponse(JSONObject resposne) { //other stuff goes

类型转换

天涯浪子 提交于 2019-12-03 11:39:31
CommonResponse<UserAccountsModule> userAccounts = JSONObject.parseObject(result, new TypeReference<CommonResponse<UserAccountsModule>>(){}); Map<String,List<JSONObject>> permissonMap = JSONObject.parseObject(permissionStr, new TypeReference<Map<String, List<JSONObject>>>(){}); 来源: https://www.cnblogs.com/qqq9527/p/11794384.html

Unable to trigger geojson marker over a google-map android

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm showing a geojson file as a layer over a google map android app. Everything works ok, but I'm not be able to trigger on click in geojson markers. I have adapted the code in: https://github.com/googlemaps/android-maps-utils/blob/master/demo/src/com/google/maps/android/utils/demo/GeoJsonDemoActivity.java but in line 142: layer.setOnFeatureClickListener(new GeoJsonLayer.GeoJsonOnFeatureClickListener() { I get: cannot resolve method 'setOnFeatureClickListener()' This is my code in onPostExecute; @Override protected void onPostExecute

JSON parsing app “no data”?

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here's the code for my JSON parsing app. It force closes as soon as I run it on my emulator. I am new to Android programming, and I'm self taught so please bear with me. Thanks! JSONfunctions.java: package com.pxr.tutorial.json; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http

Unable to find a default constructor to use for type System.Json.JsonObject

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to return some twitter data, but I am not able to complete my task. using System.Collections.Generic; using System.Json; using System.Linq; using System.Net.Http; using System.Web.Mvc; using Demo.Models; namespace Demo.Controllers { public class HomeController : Controller { public ActionResult Index() { var model = new List<Tweets>(); var client = new HttpClient(); var task = client.GetAsync("http://search.twitter.com/search.json?q=dave").ContinueWith((taskWithMessage) => { var response = taskWithMessage.Result; var jsonTask =

How to get data as an json array from a server and convert it in to java array to use in android application

匿名 (未验证) 提交于 2019-12-03 08:56:10
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible duplicate How to parse a JSON and turn its values into an Array? [ [ "sn1" , "Liquid_level" , "85" ], [ "sn2" , "Liquid_level,Temperature" , "95" ], [ "sn2" , "Liquid_level,Temperature" , "50" ], [ "sn3" , "Liquid_level" , "85.7" ], [ "sn4" , "Liquid_level" , "90" ], [ "sn5" , "Volt_meter" , "4.5" ], [ "sn6" , "Temperature" , "56" ], [ "sn8" , "Liquid_level" , "30" ] ] This is the data i want to get to a java array (to create a dynamic table to show data). i can get a text value using this String response = null ; try { response =

JSONObject - How to get a value ?

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i'm using a java class on http://json.org/javadoc/org/json/JSONObject.html . The following is my code snippet. String jsonResult = UtilMethods.getJSON(this.jsonURL, null); json = new JSONObject(jsonResult); getJSON returns the following string {"LabelData":{"slogan":"AWAKEN YOUR SENSES","jobsearch":"JOB SEARCH","contact":"CONTACT","video":"ENCHANTING BEACHSCAPES","createprofile":"CREATE PROFILE"}} Now...how do I get the value of 'slogan' ? I tried all the methods listed on the page, but none of them worked. 回答1: String loudScreaming = json

Remove JSON object from JSONArray - Jettison

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a direct way to remove an JSONObject stored in the JSONArray by using index. I tried all the possibilities. Still not able to remove the JSON object from the JSON Array. Any hint will be helpful Thanks 回答1: In java-json , there is no direct method to remove jsonObject, but using json-simple , it is simple to do so: JSONArray jsonArray = new JSONArray(); JSONObject jsonObject = new JSONObject(); JSONObject jsonObject1 = new JSONObject(); JSONObject jsonObject2 = new JSONObject(); jsonObject.put("key1", "value1"); jsonObject1.put(

Android JSON Object

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a JSON format like this {"response":{"status":true,"result":"user_exists"}} Now i am trying to retrieve the Status value to do some logic JSONObject jData = new JSONObject(data); JSONArray response = jData.getJSONArray("response"); But i am getting the following error org.json.JSONException: Value {"result":"user_exists","status":true} at response of type org.json.JSONObject cannot be converted to JSONArray how to retrieve an Object from inside and Object ? 回答1: you are trying to retreive the status attribut from a JSONArray but , you