jsonarray

周报导入导出(excel)

谁说我不能喝 提交于 2019-12-03 23:48:08
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.usermodel.BorderStyle; import org

浅谈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": "感冒指数",

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

Java return JSONArray

匿名 (未验证) 提交于 2019-12-03 09:13:36
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to create a jsonarray from a Map in java. I'm passing it in to a javascript variable. But i don't know why the mac and status are blank, any help much appreciated. what i need: [{"12345":{"mac":"FFFFFFFF", "status":"ON"}] What i am getting with my current code: [{"12345":{}] Here is my code, public class Details { public JSONArray getResult() { return JSONArray.fromObject(this.det); } public Map det = new HashMap(); public results() { ResultSet rs; det.put(rs.getString(1), new NodeDetails(rs.getString(2), rs.getString(3)); } class

Error java.lang.RuntimeException: Stub! in Android with Fitnesse testing

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to create a test fixture using Fitnesse framework, and I want to test a function which retrieves data from a server (RESTFUL service). My test case is very simple: public class FriendListActivityFixture extends ColumnFixture { public int URL; public String test() { JSONArray array = JsonHelper.getJsonArrayFromUrl("http://107.22.209.62/android/get_users.php"); return array.toString(); } } public static JSONArray getJsonArrayFromUrl(String url) { InputStream input = null; String result = ""; JSONArray jsonArray = null; try {

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(

JSONObject Not Serializable?

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to serialize an ArrayList of JSONObjects. But I get the error: 05-07 01:04:24.130: WARN/System.err(913): java.io.NotSerializableException: org.json.JSONObject 05-07 01:04:24.130: WARN/System.err(913): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1535) 05-07 01:04:24.130: WARN/System.err(913): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847) 05-07 01:04:24.130: WARN/System.err(913): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689) 05-07 01:04:24.130:

Parse a JSON Object With an Undetermined Amount of Child Nodes

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I working with the Dropbox API and I would like to get the folders and paths from a json object. However I am having problems as there is an undermined number of child nodes. How would I go about parsing something like this? EDIT The JSONObject represents a directory. The top level folder is represented by a json object. Within that object are the sub-folders. Each of them has there down JSONobject, within each of these jsonobject there is an array which represent the subfolders of the subfolder. So I don't know the complete structure of the

A JSONArray text must start with '[' at 1 [character 2 line 1]

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a JSON file and i am trying to deal with but the following error is appears: Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1] at org.json.JSONTokener.syntaxError(JSONTokener.java:433) at org.json.JSONObject.(JSONObject.java:195) at org.json.JSONObject.(JSONObject.java:319) at amazondataset.AmazonDataset.main(AmazonDataset.java:11) Java Result: 1 This is a sample of the file: { "reviewerID": "A2SUAM1J3GNN3B", "asin": "0000013714", "reviewerName": "J. McDonald", "helpful"

How to get the List of Installed Applications in Android?

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is the source code... public class GetAppList extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { List<PackageInfo> appListInfo = this.getPackageManager() .getInstalledPackages(0); JSONArray ja = new JSONArray(); for (PackageInfo p : appListInfo) { if (p.applicationInfo.uid > 10000) { JSONObject jo = new JSONObject(); jo.put("label", p.applicationInfo.name); jo.put("packageName", p.applicationInfo.packageName); ja.put(jo); } } System.out