arrays

com.google.gson.JsonObject cannot be cast to com.google.gson.JsonArray

邮差的信 提交于 2021-02-16 18:00:41
问题 I have some trouble with parsing a JSON response. The response data: { "deal": { "categorie": { "description": "Offres Shopping", "idcategorie": "1", "nom": "Shopping" }, "conditions": "2 personne au plus", "dateAjout": "2013-01-07T00:00:00+01:00", "dateExp": "2013-01-31T00:00:00+01:00", "description": "nuit dans un hotel 5 etoile", "heurexp": "12", "iddeal": "1", "minutesexp": "30", "prestataire": { "adresse": "Qu zohour 44", "codePostale": "12600", "description": "Hotel 5 etoiles",

com.google.gson.JsonObject cannot be cast to com.google.gson.JsonArray

 ̄綄美尐妖づ 提交于 2021-02-16 18:00:08
问题 I have some trouble with parsing a JSON response. The response data: { "deal": { "categorie": { "description": "Offres Shopping", "idcategorie": "1", "nom": "Shopping" }, "conditions": "2 personne au plus", "dateAjout": "2013-01-07T00:00:00+01:00", "dateExp": "2013-01-31T00:00:00+01:00", "description": "nuit dans un hotel 5 etoile", "heurexp": "12", "iddeal": "1", "minutesexp": "30", "prestataire": { "adresse": "Qu zohour 44", "codePostale": "12600", "description": "Hotel 5 etoiles",

Post array via jQuery

為{幸葍}努か 提交于 2021-02-16 17:59:05
问题 I have a form which contains some unique input fields and some others with duplicate names, like this: <form method="post"> Title: <input type="text" name="title" /><br /> Content: <input type="text" name="content" /><br /> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email" /><br /> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email" /><br /> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email"

Java: Using “08” and “09” in an array

China☆狼群 提交于 2021-02-16 16:32:06
问题 How can I store 08 and 09 into an int array? I understand that they cannot due to binary characteristics and have tried both... 0b08, 0b09 ... and ... 0B08, 0B09 with no luck. The following line of code is ideally what I'd like to have: final int[] monthValidDosInputs = {00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12}; Here is the error... ConvertDate.java:15: error: integer number too large: 08 ConvertDate.java:15: error: integer number too large: 09 Thanks! 回答1: When you start a literal

Transpose of a matrix in numpy

三世轮回 提交于 2021-02-16 16:18:09
问题 I have this numpy array: a = np.array([[[1,2,3],[-1,-2,-3]],[[4,5,6],[-4,-5,-6]]]) b is a transpose of a . I want b be like this: b = np.array([[[1,-1],[2,-2],[3,-3]],[[4,-4],[5,-5],[6,-6]]]) Is it possible to do it in one line? EDIT: And if I have this instead: a = np.empty(3,dtype = object) a[0] = np.array([[1,2,3],[-1,-2,-3]]) a[1] = np.array([[4,5,6],[-4,-5,-6]]) How can I get b? 回答1: You can do it using np.transpose(a,(0,2,1)) : In [26]: a = np.array([[[1,2,3],[-1,-2,-3]],[[4,5,6],[-4,-5

Proper way to initialize a std::array from a C array

冷暖自知 提交于 2021-02-16 16:14:29
问题 I'm getting an array from a C API, and I'd like to copy this to a std::array for further use in my C++ code. So what is the proper way of doing that ? I 2 uses for this, one is: struct Foo f; //struct from C api that has a uint8_t kasme[32] (and other things) c_api_function(&f); std::array<uint8_t, 32> a; memcpy((void*)a.data(), f.kasme, a.size()); And this class MyClass { std::array<uint8_t, 32> kasme; int type; public: MyClass(int type_, uint8_t *kasme_) : type(type_) { memcpy((void*)kasme

Java comparing Arrays

六眼飞鱼酱① 提交于 2021-02-16 15:57:09
问题 I have two Arrays of unknown type...is there a way to check the elements are the same: public static boolean equals(Object a , Object b) { if (a instanceof int[]) return Arrays.equals((int[]) a, (int[])b); if (a instanceof double[]){ ////etc } I want to do this without all the instanceof checks.... 回答1: ArrayUtils.isEquals() from Apache Commons does exactly that. It also handles multi-dimensional arrays. 回答2: You should try Arrays.deepEquals(a, b) 回答3: Arrays utilities class could be of help

How to save numpy ndarray as .csv file?

狂风中的少年 提交于 2021-02-16 15:51:05
问题 I created a numpy array as follows: import numpy as np names = np.array(['NAME_1', 'NAME_2', 'NAME_3']) floats = np.array([ 0.1234 , 0.5678 , 0.9123 ]) ab = np.zeros(names.size, dtype=[('var1', 'U6'), ('var2', float)]) ab['var1'] = names ab['var2'] = floats The values in ab are shown below: array([(u'NAME_1', 0.1234), (u'NAME_2', 0.5678), (u'NAME_3', 0.9123)], dtype=[('var1', '<U6'), ('var2', '<f8')]) When I try to save ab as a .csv file using savetxt() command, np.savetxt('D:\test.csv',ab

What is the python equivalent of JavaScript's Array.prototype.some?

吃可爱长大的小学妹 提交于 2021-02-16 15:46:35
问题 Does python have any equivalent to JavaScript's Array.prototype.some / every? Trivial JavaScript example: var arr = [ "a", "b", "c" ]; arr.some(function (element, index) { console.log("index: " + index + ", element: " + element) if(element === "b"){ return true; } }); Will output: index: 0, element: a index: 1, element: b The below python seems to be functionally equivalent, but I do not know if there is a more "pythonic" approach. arr = [ "a", "b", "c" ] for index, element in enumerate(arr):

Java Performance: multiple array vs single array of custom object [closed]

允我心安 提交于 2021-02-16 15:37:18
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . Improve this question What's the best performance of these two different code solution: class Meme { private int[] a = new int[100]; private int[] b = new int[100]; private int[] c = new int[100]; } vs class Meme { private MemeProp[] prop = new MemeProp[100]; class MemeProp {