jsonobject

How to pass the JSONArray from one JSP to another JSP and show the results in table?

落花浮王杯 提交于 2019-12-11 18:08:48
问题 Below is my JSP page (abc.jsp) from which I am calling another JSP page jspConnection.jsp using the jQuery and then jspConnection.jsp will return me back the query result to abc.jsp and then I need to use the result to show them in a table - Below code I have in abc.jsp from which I am calling jspConnection.jsp - $.post("jspConnection.jsp", {'id': id}, function (data) { // make a new table here from JSONObject // and show the result here } ); Table should look like this in abc.jsp after

Parse.com REST API Error Code 400: Bad Request from Java HTTP Request to Cloud Function

橙三吉。 提交于 2019-12-11 11:40:47
问题 I have a string that I am trying to send to a Parse.com cloud function. According to the REST API documentation (https://www.parse.com/docs/rest#general-requests), it must be in json format, so I made it into a json object and converted it to a string to append to the end of the http request url. JSONObject jsonParam = new JSONObject(); jsonParam.put("emailId", emailId); String urlParameters = jsonParam.toString(); Then I send the request as so, in my attempt to match their cURL code example

Android app returning inner arrays as [ ] or ArrayList memory allocation?

回眸只為那壹抹淺笑 提交于 2019-12-11 10:45:47
问题 Hi I am new to Java and android and I'm trying to parse data from linked classes but I can not work out how to retrieve jsonObjects from some of the inner/nested JSONArrays? I can retrieve objects from the outer JSONArray's but I can not see how to retrieve the nested JSONArray list objects from segments inner JSONArrays within the StorlineData class. When I try to parse data from the inner/nested JSONArrays the response looks like this: Thanks in advance for your help. JSON (I am unable to

How can I put key with null value in net.sf.json.JSONObject?

♀尐吖头ヾ 提交于 2019-12-11 10:20:33
问题 I am using net.sf.json.JSONObject . It will remove key if my value is null while I am trying to put data in Json object using put method. Is there any way to keep my key as it is in my object even my value is null? for ex. JSONObject json = new JSONObject(); json.put("myKey",null); Then my output is : {} But I want output : {"myKey",""} How can I do? 回答1: json.put("myKeyu",JSONObject.NULL); More details here. 回答2: JSONObject.NULL is for Apache Commons JSONObject. Try the following instead:

How to use Jackson ObjectMapper to convert to Pojo for multiple data

大兔子大兔子 提交于 2019-12-11 06:45:53
问题 I would like to convert the following string/ JSONObject to POJO, {"list":["\r\n{\r\n\"id\":\"1\",\r\n\"protocol\":\"udp\",\r\n\"srcPorts= \":\"3000-4000 \",\r\n\"destPorts\":\"1790-2000\"\r\n}","\r\n{\r\n\"id\":\"2\",\r\n \"protocol\":\"tcp\",\r\n\"srcPorts\":\"3000-4000\",\r\n\"destPorts\":\"1790-2000 \"\r\n}"],"user":"\r\n{\r\n\"name\":\"John\",\r\n\"address\":\"x.x.x.x\",\r\n\"email \":\"john@p.com\"\r\n}"} How do I convert to Pojo using Jackson ObjectMapper. The 2 Pojo classes are as

How to access invidual json objects from a json array?

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:33:19
问题 I have the following response, and I want to display all eqid 's in invidual TextView 's, but I don't know how to achive this, below is my snippet code and response to get data from the server and display in textview. Can anyone help me with this? { "earthquakes":[ { "eqid":"c0001xgp", }, { "eqid":"c000905e", }, { "eqid":"2007hear", }, { "eqid":"c00090da", }, { "eqid":"2007aqbk", }, { "eqid":"2007hec6", }, { "eqid":"a00043nx", }, { "eqid":"2010utc5", }, ] } Code ServiceHandler sh = new

How to write a JSONObject to a file, which has JSONArray inside it, in Java?

别说谁变了你拦得住时间么 提交于 2019-12-11 02:57:01
问题 I have JSON file, that I need to read, edit and write out again. Reading works fine, I struggle with the write part of the JSON Array in my data. I use JSON.simple library to work with JSON in Java. The file looks like this: { "maxUsers":100, "maxTextLength":2000, "maxFileSize":2000, "services": [ { "serviceName":"Яндекc", "className":"YandexConnector.class", "isEnabled":true }, { "serviceName":"Google", "className":"GoogleConnector.class", "isEnabled":false } ] } When I try to write JSON

json数据构造

强颜欢笑 提交于 2019-12-10 22:19:45
public class JsonServerlet extends HttpServlet{ @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); //1.普通生成json数据 JSONObject jsonObject = new JSONObject(); jsonObject.put("key","value"); out.println(jsonObject); out.println("</br>"); //2.通过list生成json数据 List list = new ArrayList(); list.add("first"); list.add("second"); list.add("third"); JSONArray jsonArray = JSONArray.fromObject(list); out.println(jsonArray); out.println("</br>"); //3.通过map生成json数据 Map

常用转换工具

做~自己de王妃 提交于 2019-12-10 19:57:20
常用的转换工具 读取文件转string 输入流转document inputstream转json 复制流 读取文件转string private static String readString3() { String str = ""; File file = new File(path); try { FileInputStream in = new FileInputStream(file); int size = in.available(); byte[] buffer = new byte[size]; in.read(buffer); in.close(); str = new String(buffer, "utf-8"); } catch (IOException e) { return null; } return str; } 输入流转document public static Document isToDoc(InputStream is) throws Exception{ DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); DocumentBuilder builder =

Java 工具篇(百度文字识别)

て烟熏妆下的殇ゞ 提交于 2019-12-10 16:30:55
背景: 公司项目需要上传省份证,营业执照等图片,需要获取里面的信息。所以使用了百度文字识别,方便快捷 主要是免费的,虽然一天是有限数的;本来百度上的API文档很清楚了,但是现在还是稍微了的整理下。 首先添加一个百度的jar包 <!-- https://mvnrepository.com/artifact/com.baidu.aip/java-sdk --> <dependency> <groupId>com.baidu.aip</groupId> <artifactId>java-sdk</artifactId> <version>4.11.3</version> </dependency> 其次随便创建一个类,然后配置必要的数据 上面的都是开通百度识别可以看到的配置数据,所以现在就不做描述了。 public static AipOcr aipOcr(){ AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY); return client; } 为了方便所以我写了一个方法来实例化AipOcr类,下面就是具体的方法体了。 /** * 身份证验证 * * @param client * @param url * @param idCarSide front - 身份证含照片的一面 back - 身份证带国徽的一面 *