nested

Java: Deserializing JSON structure to Map<String, Object>

蓝咒 提交于 2019-12-05 18:53:10
I've got a JSON string that I want to convert to a Map structure where Object is either a Java version of a basic type (i.e. String, Int, Double), a Map. or a List. The sample string I'm using for my tests is: "{\"cases\":[{\"documents\":[{\"files\":[{\"name\":\"a.pdf\"}]}]}]}" This should read as an array of cases that each have an array of documents, that each have an array of files, that each have a name I've tried Google's Gson, but Gson gson = new Gson(); List<Map<String, Object>> results = gson.fromJson(dictString, List.class); gives me: com.google.gson.JsonParseException: The

How to filter rows on nested values in a json column?

风格不统一 提交于 2019-12-05 18:10:26
Here is my table (simplified, only significant columns): CREATE TABLE things ( id serial primary key , name varchar , blueprint json default '{}' ); And some sample data: # select * from things; id | name | blueprint ----+---------+----------------------------------------------------------------------------- 1 | Thing 1 | {} 2 | Thing 2 | {"1":{"name":"Iskapola","wight":"2"}} 3 | Thing 3 | {"1":{"name":"Azamund","weight":"3"}, "2":{"name":"Iskapola","weight":"1"}} 4 | Thing 4 | {"1":{"name":"Ulamir","weight":"1"}, "2":{"name":"Azamund","weight":"1"}} I'd like to select rows that have 'Azamund'

How to load a nested csv file in aerospike using aerospike loader?

橙三吉。 提交于 2019-12-05 18:01:42
I have converted JSON file to CSV format and now loading the CSV in Aerospike using aerospike loader. I can do this for simple structure but how to modify the contents of allDatatype.json to load the nested CSV file in Aerospike? https://github.com/aerospike/aerospike-loader/tree/master/example JSON FILE { "centers" : { "ER" : { "admin":{ "users" : { "emp1" : { "password" : "abcdefgh", "username" : "pankaj-roy" }, "emp2" : { "password" : "12345678", "username" : "niketan-shah" } } } } } } CSV FILE centers.ER.admin.users.emp2.username,centers.ER.admin.users.emp2.password, centers.ER.admin.users

Deepcopy on nested referenced lists created by list multiplication does not work

笑着哭i 提交于 2019-12-05 17:21:29
As much as I love Python, the reference and deepcopy stuff sometimes freaks me out. Why does deepcopy not work here: >>> import copy >>> a = 2*[2*[0]] >>> a [[0, 0], [0, 0]] >>> b = copy.deepcopy(a) >>> b[0][0] = 1 >>> b [[1, 0], [1, 0]] #should be: [[1, 0], [0, 1]] >>> I am using a numpy array as a workarround which I need later on anyway. But I really had hoped that if I used deepcopy I would not have to chase any unintended references any more. Are there any more traps where it does not work? It doesn't work because you are creating an array with two references to the same array. An

Triple nested quotations in shell script

徘徊边缘 提交于 2019-12-05 16:46:29
I'm trying to write a shell script that calls another script that then executes a rsync command. The second script should run in its own terminal, so I use a gnome-terminal -e "..." command. One of the parameters of this script is a string containing the parameters that should be given to rsync. I put those into single quotes. Up until here, everything worked fine until one of the rsync parameters was a directory path that contained a space. I tried numerous combinations of ',",\",\' but the script either doesn't run at all or only the first part of the path is taken. Here's a slightly

Javascript: Access nested values in JSON data using dynamic variable names

折月煮酒 提交于 2019-12-05 16:43:17
问题 I have a nested Javascript object like var data = { 'name': { 'heading': 'Name', 'required': 1, 'type': 'String' }, 'profile': { 'age': { 'heading': 'Age', 'required': 0, 'type': 'Number' }, 'phone': { 'heading': 'Phone', 'required': 0, 'type': 'String'}, 'city': { 'heading': 'City', 'required': 0, 'type': 'String'}, }, 'status': { 'heading': 'Status', 'required': 1, 'type': 'String' } }; Here, I can access the fields as data.profile.age.type or data.name.type. No Issues And if I have dynamic

Nested class definition outside outer class's, while outer class contains instance of inner class

喜夏-厌秋 提交于 2019-12-05 16:30:29
C++ How can I put the definition of an inner (nested) class outside its outer (enclosing) class's definition, where the outer class has at least one instance of the inner class as a data member? I searched but the most relevant SO answer I found, Nested Class Definition in source file , does not have an example where the outer class has an inner object as a data member. I followed that answer, as far as declaring but not defining the inner class inside the outer class's definition is concerned, but my code is still broken: struct Outer { struct Inner; Inner myinner; Outer() : myinner(2) {} };

gradle to bundle nested jar dependencies into module output jar

一个人想着一个人 提交于 2019-12-05 16:18:17
How to make gradle to included some dependencies into module resulted jar as jar? i.e. to make jar with nested jar's e.g. in lib folder ? This is not Android project, and this should be done for many modules in multi-module project, so fatJar, uberJar, shadowJar alike solutions seem not to fit. You just need to add an additional from directive to include dependencies in your jar: task jarJar(type: Jar) { baseName = project.name + '-jarjar' from { configurations.compile } with jar } 来源: https://stackoverflow.com/questions/36336709/gradle-to-bundle-nested-jar-dependencies-into-module-output-jar

python how to search an item in a nested list

本小妞迷上赌 提交于 2019-12-05 16:06:49
say I have this list: li = [["0", "20", "ar"], ["20", "40", "asdasd"], ["50", "199", "bar"], ["24", "69", "sarkozy"]] Now, forget about the numbers, they are something that let me recognize the position of string. So basically, given that I have the string "ar" in hand, how can I extract all the lists that contain "ar"? new_li = [["50", "199", "bar"], ["24", "69", "sarkozy"]] How can I obtain this list? >>> [x for x in li if 'ar' in x[2]] [['0', '20', 'ar'], ['50', '199', 'bar'], ['24', '69', 'sarkozy']] 来源: https://stackoverflow.com/questions/6889785/python-how-to-search-an-item-in-a-nested

python nesting dictionary: OrderedDict from collections

空扰寡人 提交于 2019-12-05 15:59:46
how to nest a OrderedDict? i tried: table=collections.OrderedDict() table['E']['a']='abc' but this shows error. i tried also: table=collections.OrderedDict(OrderedDict()) table['E']['a']='abc' this also shows error. i tried: table=collections.OrderedDict() table['E']=collections.OrderedDict() table['E']['a']='abc' this works fine. in my coding i had to use like this: table=collections.OrderedDict() for lhs in left: table[lhs]=collections.OrderedDict() for val in terminal: table[lhs][val]=0 which works fine. but is there any other method. as i read python manages its data structure