FAQ Database Discussion Community


How to build out this complex Array based on this Simple Object

javascript,arrays,object,lodash
http://jsfiddle.net/leongaban/tuhgns3q/ My simple object: { portfolio: "AAPL", t1_tag1: "1111", t2_tag1: "2222", t3_tag1: "3333", ticker1: "AA", ticker2: "GOOG", ticker3: "AAPL" } The desired end result below. Array with Objects containing Array of Objects: [ 0:Object { tags: [ 0:Object { t1_tag1: "1111" } ] ticker: ticker1 }, 1:Object { tags: [...

Unable to extract values from object array, to which javascript array was deserialized

c#,arrays,object,serialization
var serializedArray = new JavaScriptSerializer().Deserialize<object[]>(filter); The content of the variable filter is [["Title","contains","foo"],"and",["Name","contains","foo"]]. Content of serializedArray is "object[3]","and","object[3]". Content of serializedArray[0] is object[3] which are "Title", "contains", "foo". serializedArray can be used with index operator, and foreach is applicable. But not for serializedArray[0]. Funny enough, both the serializedArray and serializedArray[0]...

Object Variable or With Block Variable Not set in loop using find function

vba,excel-vba,loops,object,find
Sub Main() Dim FName As Variant, R As Long, DirLoc As String, i As Integer R = 1 i = 1 DirLoc = ThisWorkbook.Path & "\" 'location of files FName = Dir(DirLoc & "*.csv") Do While FName <> "" ImportCsvFile DirLoc & FName, ActiveSheet.Cells(R, 1) R = ActiveSheet.UsedRange.Rows.Count + 1...

Javascript Sorting Array of Objects [duplicate]

javascript,arrays,sorting,object
This question already has an answer here: Sorting an array of JavaScript objects 14 answers (Please excuse any errors - this is my first post and I am also relatively new to Javascript) I'm trying to sort an array of objects by a specific property value in Javascript. I...

How to get the public objects

php,object,guzzle,rackspace-cloud,rackspace
I'm working on PHP with Rackspace API, this is what I have used here: $file->setContent(fopen('sites/default/files/rackspace/' . $end_element, 'r+')); $cdnUrl = $file->getPublicUrl(); print_r($cdnUrl); And its returning me the below mentioned structure. Guzzle\Http\Url Object ( [scheme:protected] => http [host:protected] => something.r2.cf3.rackcdn.com [port:protected] => [username:protected] => [password:protected] => [path:protected] => /something-abc.jpg [fragment:protected] =>...

Is a Java class variable a reference to a class object?

java,class,object,reference
I know such question has been asked before but I couldn't find a satisfactory answer. Assume a java class : class Foo{ public int k; Foo(int a){ k=a; } } class My{ public static void main(String args[]){ Foo obj = new Foo(5);//1 obj=new Foo(8); //2 } } I want to...

Adding the values from an object to an array of objects without overriding existing key values

javascript,arrays,object,underscore.js
How do you go from this: var array = [{key: [3]}, {key1: [3]}, {key1: [3]}] var object = {key1: [3], key2: [3]}; to this: {key: [3], key1: [9], key2: [3]} All "key" are a userIds like "LQVjUacPgK" as seen in the obj example below. [N] = is an array of...

Unhandled Exception when calling SipProfile.Builder from Android SIP Class

java,android,object,android-studio,compiler-errors
There is an error when creating a Builder object. This is my code: SipProfile.Builder builder = new SipProfile.Builder("address","username"); The error:: unhandled exception: java.text.ParseException This is a sample from Android Reference.: public SipProfile mSipProfile = null; ... SipProfile.Builder builder = new SipProfile.Builder(username, domain); builder.setPassword(password); mSipProfile = builder.build(); http://developer.android.com/guide/topics/connectivity/sip.html#manager...

how to find a specific objet in a liste of object (other way than a loop)

php,loops,object
I would like to know if it is possible to easily retrieve an object from a list through its id (or any other way). So far to do so I have to do a loop and test each object to see if it is the correct one. EXEMPLE Here as...

How to iterate an object and build a new one

javascript,object,nested
I am using JavaScript to iterate customers in an object which is constructed as follows: [ { "customer": "Customer 1", "project": "1" }, { "customer": "Customer 2", "project": "2" }, { "customer": "Customer 2", "project": "3" } ] I wish to build a new object in iteration which would be...

Trouble converting from JSON to C# objects - how do the classes work?

c#,json,object
{ "device": "Lamp", "type": "Switch", "commands": [ { "name": "turn Lamp on", "command": "/api/Lamp/ON" }, { "name": "turn Lamp off", "command": "/api/Lamp/OFF" } ] } I need to deserialize the JSON into a(n) C# object(s). I am having trouble though understanding how to format the C# code. I used json2csharp.com...

How can I traverse a multi level php object and unset the deepest node dynamically

php,object,unset
I have an object that is in the form: CommentID: [ "UserID": UserID, "Status": "active/deleted", "DateTime": "DateTime", "Comment": "CommentText", "Likes": [ UserID: DateTime of Like, UserID: DateTime of Like... ], "Comments": [same as parent] ] This means, I could have multiple levels of comments -> A comment on a comment...

jQuery function callback does not work in custom class/object

javascript,jquery,class,object,callback
So am a newbie to programming so excuse me if this is a novice question. I am creating a simple wave effect to create an illusion of moving water. I did this with a simple function in jquery and it worked fine. I am learning OOP so my code is...

Empty object in Javascript

javascript,object
I have a weird situation. I take some values from a form and save it in an object. I print out the values and it prints fine to the console log. But when I try to access it or print again in next line. It returns empty. Here is the...

NodeJS: trouble emitting array inside object to client

javascript,arrays,node.js,object
Trying to keep track of client sockets myself inside of a data object. var clients = {'clients':[]}; io.sockets.on('connection', function(socket) { clients.clients.push(socket); io.emit('updateUsers', clients); }); Getting this error: RangeError: Maximum call stack size exceeded. I thought that making clients an object rather than an array would solve the call stack error,...

Search for object in multiple arrays in an object based on the ID with JavaScript

javascript,arrays,object
I need a way of searching a JSON object based on an ID in the object. I want to use the data in the object for a JS template. In the moments object there are multiple (data-stamped named) arrays containing multiple objects. I am happy to use jQuery. Here is...

Use checkboxes to filter to a new array of objects - javascript

javascript,arrays,function,object,checkbox
I have an array of objects: var array = [ {"date":"Jan 1", "job":"teacher"}, {"date":"Jan 1", "job":"lawyer"}, {"date":"Jan 2", "job":"doctor"}, {"date":"Jan 4", "job":"doctor"} ]; I want to use checkboxes to filter by "job" and then have a new separate array of objects that is filtered (leaving the original array intact). I'd...

In Java, How do I cast a Realm Object into the class I wish to write to the Database?

android,class,object,casting,realm
I am currently working on a project where my Database has a very large number of tables (Approx 60 total). I am working to create the Database Helper class that will function as the writer/ reader to/ from the database. And example of my write method would be this: public...

Search inside objects javascript

javascript,object,firebase
I'm experimenting on login with firebase. I can make an account, and it'll store additional information too. The problem is retrieving this information. I can get it using: usersRef.on("value", function(snapshot) { console.log(snapshot.val()) }, function (errorObject) {...}); When I do this I get two things (because I have two accounts): -JrrzEOqZQU0HVeYVXCm:...

How to get specific value of an dictionary

c#,object,dictionary,filter
i have an Dictionary of type int, myclass. in myclass i have following attributes: an string, int, and an string array. Evrything works fine when i save the data in dictionary. But i want now to look in the dictionary, if there is an value, in myclass, at the position...

ActionScript: How to call an objects function within an array?

arrays,flash,object,actionscript
In Java it is possible to set the datatype of an array, and by setting the datatype to the object I am using, I can call the methods and variables of that object. For instance: ArrayList<Object> name = new ArrayList<Object>(); name.add(new Object(variables)); name.get(0).method; Is there any way I can do...

Javascript setting object with variable [duplicate]

javascript,object
This question already has an answer here: How do I add a property to a Javascript Object using a variable as the name? 2 answers I'm trying to set up an object using a variable. Here's what I have: var sortby = 'post_date'; var sort = { sortby :...

Use of self when creating objects in Python

python,object,self
I made several classes which are doing the same thing, but I still don't completely understand the difference, and which is best to use. Also, the 4th object is not working. It says 'NameError: name 'self' is not defined', although I don't understand what is going wrong. This is what...

Inner class declaration and initialization

java,class,object,nested,inner-classes
I am used to code in C++, but have to convert a project from C++ to Java. In C++ using data structure is pretty much simple. I am trying to replicate the same thing, but such as a Java inner class and static nested class. After reading several examples online,...

Parsing JSON object within a JSON response [duplicate]

javascript,json,object
This question already has an answer here: Access / process (nested) objects, arrays or JSON 6 answers I'm trying to get a bit of javascript working to pull back a currency conversion. Using the API from fixer.io, I'm requesting http://api.fixer.io/latest?symbols=USD&base=GBP I get an object back, but I don't know...

Excel vba code using ThisWorkbook.Sheets(1).Range not working, but Sheet1.Range works fine. Why?

excel,vba,excel-vba,object
When I use wb.Sheets(1).Range("A:A").Find(What:=ID, LookIn:=xlValues) I get error 91 - Object Variable or With Block not set. When I use Sheet1.Range("A:A").Find(What:=ID, LookIn:=xlValues) it returns correct value. Why the difference? Is there a flowchart I can reference or any simple information available to understand which sub-commands (I don't know the proper...

Run class methods in different threads

java,multithreading,object,methods
Let's suppose I have this class: public class Myclass { method1(); method2(); method3(); } I want to know if there's a way to run all 3 methods in different threads simultaneously. Is there a way to create a class MyThread : public class MyThread{ //implementation } in way that it...

Javascript: Access function within deep object on parse

javascript,oop,object
I have an object var object1 = { object2: { function1: function(a, b, c, d, e) { //do some stuff with those parameters console.log('values are ' + a + ' ' + b + ' ' + c + ' ' + d); }, function2: object1.object2.function1(2, 3, 4, 5) }...

sort list of objects in VB.NET by two elements

vb.net,list,sorting,object
I would like an extension of a question previously posted here Sort a List of Object in VB.NET In that question, the OP is asking how to sort a list of objects in VB.NET. His example uses something like passenger.name passenger.age passenger.surname And then, the accepted answer uses theList.Sort(Function(x, y)...

I'm using AngularFire, How can I retrieve this “email”, “uid” data?

angularjs,object,firebase,angularfire
JS CODE var myFirebaseRef = new Firebase('https://blinding-inferno-7068.firebaseio.com/'); var createdUserRef = myFirebaseRef.child('users').child('createdUser'); $scope.users = $firebaseArray(createdUserRef); HTML CODE <ul ng-repeat="user in users"> <li>{{user.uid}}</li> <li>{{user.email}}</li> <li>{{user}}</li> </ul> What I wanted was user.uid and user.email, but those thing didn't come out. So I checked the user object, and these things came out....

Java How create a set of object with two classes?

java,object,set
I have a logical problem to understand, how create a private set of inhabitant object. Here my two classes: package main; import java.util.Set; /** * @author * @version 0.1 * */ public class City { private String name; /** *HERE is my Problem*/ private Set<Inhabitants> Inhabitants { } /** *...

How to set another object inside another object | JavaScript

javascript,object
I don't know if this question's been answered yet but I'd still ask. Pretty confused over this one, and it might be simple but nonetheless, here goes: I want to turn this already set object (meaning i have no access to it, just getting it from the server): Object: {...

Extending JFrame - how does “super” keyword work?

java,object,jframe,super
I've made a class that extends JFrame, and in my classes constructor, to set the title I can either use: super("title"); setTitle("title"); or just create a JFrame object i.e: JFrame f = new JFrame("title); How does the compiler differentiate from all of these to conclude the same thing? I know...

Object.length undefined in javascript [duplicate]

javascript,arrays,object
This question already has an answer here: Length of a JavaScript object (that is, associative array) 21 answers I have an javascript object of arrays like, var coordinates = { "a": [ [1, 2], [8, 9], [3, 5], [6, 1] ], "b": [ [5, 8], [2, 4], [6, 8],...

How do I create multiple instances of a object in javascript during runtime?

javascript,object
Trying to finish up an assignment and I can't seem to find get around this: Here's what is being asked: "Your JavaScript program should parse the user’s inputs. For each input, you should create a JavaScript object of Shopper to hold the data parsed from user’s input. Make sure that...

initializing python object with nothing but keyword args

python,object,constructor,instantiation
I am wondering how to initialize an object in python with only named args, and nothing else, if this is possible. If the order of self.name = name and self.age = age are swapped, the error is with initializing age. I have these given as keyword args to the object,...

Persist Object's value after copying in Java

java,object
My sample code - private final DataObj dataObj = getDataObjs(); private final DataObj dataObj1 = new DataObjImpl(); dataObj1 = dataObj; //I need the value of dataObj1 to be the same even if the value of dataObj is modified anywhere further down in a class. My problem is that if the...

Matlab - object orientated with abstract Interface - How creating object?

matlab,object
Hello lovely community, i am quite new here, but still hope someone can help me out. I just worked a bit with Matlab in the past and want to do a new project. Earlier I just stored all in one Matlab file and didn't had the need to use classes....

Count number of items in an array of objects with a specific property value (JavaScript)

javascript,arrays,object,d3.js
I have an array of objects. Note that "created" sometimes has the same value more than once. Also note that "status" is sometimes "0": var array = [ {"created":"Jan 1","status":1}, {"created":"Jan 1","status":1}, {"created":"Jan 2","status":1}, {"created":"Jan 3","status":0}, {"created":"Jan 4","status":1}, {"created":"Jan 4","status":1} ]; I want a new a new array of objects...

Adding a list of data to object inisde loop

jquery,object,each
I have been attempting to add a list of values into a object/associative array so i can get a list of values from the input of a multiselect plugin. Im wanting to add the name of the input as the object key. Problem: Doesnt seem to create a list, just...

How do I compare object values that are inside an array?

php,arrays,object
I have an array containing several objects. $products = [ {"id":"1","random":"sadasd","mergethis":"Ding"}, {"id":"2","random":"assdfsadf","mergethis":"Ding"}, {"id":"2","random":"assdfsadf","mergethis":"Flop"}, {"id":"2","random":"assdfsadf","mergethis":"Bips"}, {"id":"3","random":"sdfss","mergethis":"Flung"}, {"id":"3","random":"sdfss","mergethis":"Rorg"}, {"id":"4","random":"asdasdddaf","mergethis":"Shwung"} ] I'm trying to iterate trough this array and when the id is allready present in the array, I want to add the value of mergethis...

Socket.io error in sending arrays

javascript,arrays,object,socket.io
I have 3 variables to send to the client using socket.io, namely, mapRes & location. server.js var mapRes = {width : 720, height: 1040}; var location = [{x:100,y:100,z:100},{x:200,y:200,z:200}]; var obj = {'1':{x:100,y:200}}, '2':{x:200,y:100}}; io.on("connection", function(socket){ socket.emit("mapRes",mapRes); socket.emit("location",location); socket.emit("object",obj); } client.html socket.on('mapRes',function(message){ var mapRes = message; console.log(mapRes); }); socket.on('location',function(message){ var location...

Trying to get property of non-object (valid json) [duplicate]

php,json,object
This question already has an answer here: How can I access an array/object? 3 answers Just a real quick question please, I have this string that came from my query I am able to display the string using xx = dd($sumx) which gave me the string below: string(124) "[{"total":-4107717.58,"alerx":4,"currentYear":-4107717.58,"lastYear":0,"date":2015,"value":{"debit":0,"credit":4107717.58}}]"...

odd results from nested for loops javascript

javascript,arrays,sorting,object
I'm trying to check a submitted string against a letterset. If word_string = "GAR", this should return "GAR" because these letters appear in letterset. For some reason, some words appear correctly, and some appear with missing letters. For example, with word_string = "RAG", this returns "R". "FIG" returns "FG". letterset...

Converting Object Names to Strings in AS2

string,object,for-loop,actionscript-2,movieclip
So i've made an object called "potato", then started a loop to check if something in "_level0" has the name of "_level0.potato". What i think is that since the the things in _level0 are objects instead of strings, the object name can't be recognized as a string, so im guessing...

Creation of object using abstraction fails, likely a simple fix I cannot see

java,object,constructor,abstraction
A novice question about abstraction and constructors. I feel like I'm missing something obvious. I have an abstract class Piece, this is the constructor: public abstract class Piece { private int[] location = new int[2]; private final char color; public Piece(char color, int[] location) { this.location = location; this.color =...

Calling an object and its method from another object class method

javascript,class,oop,object,methods
I have created some classes/objects for some animations. I created a class called Navigation(), and another class called Stars(). Each of the classes have their own methods and objects associated with them. I have created a method within the Navigation() class that attempts to run a method and the object...

getting access to javascript object property beginning with number

javascript,object
I am calling an api which returns an object var rain = data[i].rain; $.get( "http://api.openweathermap.org/data/2.5/forecast?q=London,uk&mode=json&units=metric", function( data ) { var data = data.list; for(var i = 0; i < 12; i++){ var rain = data[i].rain; console.log(rain) } }); rain returns the following when I inspect the console: Object {3h: 0.005}...

How to assign key to object literal when they keyname is represented by a variable?

javascript,jquery,variables,object,key
Perhaps someone can help me solve this. I'm pulling input elements' name and value out of a list like this simplified version: <ul id="options_set_1"> <li><input name="width" value="10" /></li> <li><input name="height" value="20" /></li> <li><input name="depth" value="5" /></li> </ul> The id of the ul and the names and values of the inputs...

Need help converting JSON to C# Objects

c#,asp.net,json,object,serialization
I'm currently trying to convert a JSON string into C# objects and currently am experiencing trouble during my debugging. Below is a sample of the JSON along with my classes. Classes public class Timeline_RootObject { public List<Timeline_Frame> frames { get; set; } public int frameInterval { get; set; } }...

python - When are WebSocketHandler and TornadoWebSocketClient completely deleted?

python,object,websocket,tornado,deletion
I'm working on an application that must support client-server connections. In order to do that, I'm using the module of tornado that allows me to create WebSockets. I intend to be always in operation, at least the server-side. So I am very worried about the performance and memory usage of...

MongoDB remove object from array deletes complete array

arrays,mongodb,object
I have a document like this one: { "_id" : 0, "name" : "aimee Zank", "scores" : [ { "type" : "exam", "score" : 1.463179736705023 }, { "type" : "quiz", "score" : 11.78273309957772 }, { "type" : "homework", "score" : 6.676176060654615 }, { "type" : "homework", "score" : 35.8740349954354 }...

What is this thing called in Java?

java,oop,object,inheritance,immutability
Google isn't being very friendly today, and I'm researching some OOP techniques I've not used in the past. Basically, I've noticed some libraries have variables with preset choices, like new Website(Websites.STACKOVERFLOW). What is that called, when you've got apparently immutable values like that? What if I want to create my...

Object property is undefined

javascript,object,gulp
I don't know if I'm missing something here, but for some reason a configuration object I create is always undefined upon using: gulpfile.config.js var config = { src_path: "Client/" }; gulpfile.js var config = require("./gulpfile.config.js"); gulp.task("test", function() { util.log(config.src_path); // results in 'undefined' }); Do objects have to be initialized...

PHP: how to used a class function?

php,class,object
I'm quite new and having some trial and test creating a class and objects. Here's my script: <?php class testingm { private $t; public function __construct($file) { $this->t = fopen($file, 'rb') } } $test = new testingm; $s = new file($_GET['n']); ?> the script says Warning: Missing argument 1 for...

c++: Passing objects to functions

c++,templates,object
I was going through a code where I encountered some problem and was able to crack this piece of code: #include <iostream> #include <stdint.h> #include <unistd.h> #include <errno.h> #include <vector> #include <sys/types.h> using namespace std; class abc { public: abc(int x,int y) { cout << "x:" << x << endl;...

Vector of objects from different classes

c++,class,object,inheritance,vector
I'm trying to create a vector containing objects from different classes, derived from a base class. Following answers to this question I've the following code which tries four different ways (commented out below); none of which will compile: class observable { public: virtual void observe(alglib::complex_1d_array)=0; observable() { } }; class...

Java - How to only create an object with valid attributes?

java,validation,object,constructor
I'm doing a basic Java course and I came to a problem: How do I create an object only if I have passed valid parameters to the Constructor? Should I make an alternate class and call the constructor from there after the validation is realized? Or should/could I use a...

make a div in a new created window

javascript,object
I made a timer that shows up a my new created window. but, it repeats the text everytime because i write a new line. i want to make a div element in my window so i can replace (update) the text every second. object: venster = window.open('new.html','titel','width=500, height= 500'); my...

Calling methods of an object that is already stored in an ArrayList

java,arrays,object,arraylist
Everything works so far in my program but I'm having trouble with this section of my code: else if(input.equals("2")) { System.out.println("Enter the stock symbol:"); symbol2 = in.next(); System.out.println("Enter the number of shares you wish to sell:"); sellshares = in.nextInt(); String tempsymbol = ""; for(int i=0; i<array1.size(); i++) { tempsymbol =...

Dynamically create all objects contained in file

java,object,dynamically-generated
I am developing a program to mark algorithms submitted by a group of students; each student will submit their own .java files. I would like to place these .java files into a folder and run my program. My program would then instantiate each class in the folder and add it...

Don't run Object animator [closed]

java,android,object,objectanimator,animator
Why this code don't run? When run the app, i faced with stopped app error message.. ImageButton img=(ImageButton)findViewById(R.id.img0); ObjectAnimator[] imganim = new ObjectAnimator[10]; imganim[0].setTarget(img); ...

Object returns null

java,object,null
Summary: New to Java, tried looking through other posts but didn't find an answer. I'm learning inheritance and have an AddressBook class extended by a Runner class. When I write a program to test the inheritance I create a Runner object. If I get the first String parameter it returns...

php how to send this data threw curl

php,arrays,object,curl
I have to send this data threw curl: -d '{"payer": { "default_payment_instrument":"BANK_ACCOUNT", "allowed_payment_instruments":["BANK_ACCOUNT"], "default_swift":"FIOBCZPP", "contact":{"first_name":"First", "last_name":"Last", "email":"first.last@example.com" } }, }' How am I supposed to save those data into fields variable? $fields = { "payer": { "default_payment_instrument":"BANK_ACCOUNT", "allowed_payment_instruments":["BANK_ACCOUNT"], "default_swift":"FIOBCZPP", "contact":{"first_name":"First", "last_name":"Last",...

Javascript Image() object erroneously setting height and width to 0 sometimes

javascript,image,object,height,width
I'm working on an app that is dynamically generating images with Javascript's image() object. Code below, where object is the URL I am passing in - resizeImage: function(object) { var img = new Image(); img.src = object; console.log(img); console.log(img.width); console.log(img.height); var ratio; if(img.width > img.height) { ratio = 82/img.width; }...

Changing the property values of an object in an array using another property value

javascript,arrays,object
I have an array as below. What I'd like to implement is a function that takes the node's ID, x and y as its inputs and make changes accordingly in the array. var nodes = [{ID:"101", x:100, y:200} ,{ID:"102", x:200, y:200} ,{ID:"103", x:300, y:300} ,{ID:"104", x:200, y:300}]; For example, function...

pretty print json directly in page from Express

json,object,express
I'd like to pretty print a large javascript object in my browser window using Express. I've tried res.json() and res.send() with pretty print turned on in express, but it looks like that only works for html and not objects. The response is only the javascript object which is all I...

a object to object mapper compatible on Android

android,object,mapper
I'm looking for an object to object mapper for Android. It's all about an automation of Java Bean to Java Bean copy so that each field with a name xyz will match a field xyz in another class. I've tried already each of those in Java http://www.javacodegeeks.com/2013/10/java-object-to-object-mapper.html But none is...

How to see if given object matches one of the objects returned from firebase

javascript,object,firebase
I am trying to test if the given object matches the stored objects that are stored and returned from firebase. If it does then return true or store true in a variable. Here is the example of given object and firebase returned data given object: {name: "John", age: "32"} stored...

Get and add all properties of type Mname from a list of objects and add them dynamically too a drop down

c#,linq,list,object,properties
Ok so I have an object type called monsters and a list of all monsters I need to get all the strings from the property called MName and add each one to a Drop down text box. here is the class so far.(sorry Im really new to coding.) using System;...

Filter array of objects with another array of objects

javascript,jquery,arrays,object,filter
This question is similar to this one Jquery filter array of object with loop but this time I need to do the filter with an array of objects. Exemple: I have an array of objects like this: myArray = [ { userid: "100", projectid: "10", rowid: "0" }, { userid:...

Difference between two types of a super class instantiation in Java [duplicate]

java,object,java-ee,instantiation,superclass
This question already has an answer here: Java: difference between A x = new A() and A x = new B() when B extends A [duplicate] 6 answers I have an abstract super class called Document and two child classes called Magazine and Book. What is the difference between...

meaning of the super keyword in the parent class python

python,object,super
I do not understand the meaning of the super keyword when it is not used in a child class. The question comes from this class here that I found on a git hub project where I am working (the link is https://github.com/statsmodels/statsmodels/pull/2374/files) Look for example at the fit method where...

Fill Javascript object with fixed length multidimensional array

javascript,arrays,object,multidimensional-array,fill
I am trying to wrap my head around javascript objects and arrays. I attempted to fill and access an object as following: obj_keys = [1,2,3,4,5,6,7]; o = {}; $.each(obj_keys, function(k, v){ o[v] = []; for(var c; c < 10; c++){ o[v][c] = []; o[v][c].push([11,12,13,14]); } }); console.log(o); Object { 1:...

javascript dynamic structure with array or object

javascript,arrays,object,dynamic
Im trying to create a structure with Javascript as follows: var users = { user.id: { session.id1: session.id1, session.id2: session.id2, session.id3: session.id3 }, user.id2: { session.id1: session.id1, session.id2: session.id2, session.id3: session.id3 }, }; What i need: add new sessions and remove them, removing okay, but how should i define object...

Spawn random objects without overlapping (Java)?

java,object,overlap,spawn
I'm developing a game in Java, and part of it requires that objects spawn at the top of the screen and proceed to fall down. I have three objects that can possibly spawn, and three possible x coordinates for them to spawn at, all stored in an array called xCoordinate[]....

Javascript - accessing an object with duplicate names

javascript,arrays,xml,object
I have an XML file that I read in to a Javascript object. This is called jsonXML. I can see the object in its entirety in the console when I log it. It is a pretty complex object with a lot of layers and duplication. I need to access some...

Moving all fields info from one object to another

java,oop,object,field
Can I somehow move all field values from one object to another without using reflection? So, what I want to do is something like this: public class BetterThing extends Thing implements IBetterObject { public BetterThing(Thing t) { super(); t.evolve(this); } } So, the evolve method would evolve one class to...

How can I retrieve the object into an array in Javascript?

javascript,arrays,object,javascript-objects
I'm currently practicing some basic problem in js and fairly new to any of these languages. I want to retrieve the value and name of the property into an array "temp" from the object "second" if the another obj "third" has the same property value. I can do it, when...

JavaScript method of object not working

javascript,object
I'm trying to create a simple object with a method that changes the value of one of the keys. I want to initialize the isFoodWarm key to false, output the value, change it to true, then output it again. My expected output is false and then true, as the method...

Getting instance of object?

java,object
I have a slight problem. I wrote a function that should generate table for a list of objects (it could be Date or custom one or whichever). Parametars of this function are "List list" and "List headings". So, here is the question, why is this line if (value.getClass().isInstance(Date.class) ... not...

How do I remove duplicate objects in an array by field in Javascript?

javascript,arrays,sorting,object
I have an array of objects: [{ id: 1, name: 'kitten' }, { id: 2, name: 'kitten' },{ id: 3, name: 'cat }] How do I remove the second kitten? Sorting into an array of names doesn't work, because I can't know if I am deleting id 1 or or...

How can I get the original type of data after being processed by Object as Hash in JavaScript?

javascript,object,hash
LeetCode 136 Single Number Given an array of integers, every element appears twice except for one. Find that single one. I have solved this problem by using Object-property in JS as Hash. However, the property only allows string type, so all the data are automatically converted to string. var singleNumber...

JavaScript objects: 'addEventListener is not a function'

javascript,html,object,canvas,mapping
I create an array of JavaScript objects called elements and loop through it in order to draw every one on a canvas as well as hooking up a few event handlers to it. However, I get an error stating that 'Uncaught TypeError: elements[i].addEventListener is not a function' Here is the...

JavaScript Saving this. variable inside of image.onLoad [duplicate]

javascript,object
This question already has an answer here: How to access the correct `this` / context inside a callback? 4 answers function InfoImage(path,title){ this.path = path; this.title = title; this.color = undefined; this.maxPixels = undefined; this.init = function(){ var canvas = document.querySelector("canvas"); var img_Color = new Image_Processing_Color(canvas); var img =...

Object Read-Only Properties

javascript,object
I was reading this question about read-only properties, and I came upon this snippet: var myObject = { get readOnlyProperty() { return 42; } }; alert(myObject.readOnlyProperty); // 42 myObject.readOnlyProperty = 5; // Assignment is allowed, but doesn't do anything alert(myObject.readOnlyProperty); // 42 Now, I know to hide the scope, you...

Creating javascript dates object

javascript,date,object
I am trying to create an object with all the dates from "today" until 60 days from now. My code: var dates = []; getDateRange(); function getDateRange() { var today = new Date(); var date = new Date(); for (var i = 0; i <= 59; i++) { date.setDate(today.getDate()+i); console.log(date);...

Is it possible to create a queue of object arrays in C++?

c++,arrays,object,queue
For example: class Hooks { public: std::string text; std::string hookfont; HookFromEncouter() { text = "Would you befriend an elf? "; hookfont = "COPRGTB.ttf"; } HookFromEncouter(string text1, string hookfont1) { text = text; hookfont = hookfont1; } }; I need to store arrays of this object in a queue: How do...

How to store the value in the object in JavaScript?

javascript,string,object
I created an object and prompt the user for the values (which are divided by a comma) but how do I then display a certain value not the whole string? Here is my code: var obj = { name: "", colors: [] }; obj = prompt("Enter your name and favorite...

Creating object name with dash

php,object
I am trying to run a mysqli query to retrieve a single result, but it requires me to create an object that contains a dash in the name, so it won't work. $style_name = $db2->query("SELECT ModelDesc-ENU FROM tlkpModel WHERE ModelID = '$style' LIMIT 1")->fetch_object()->ModelDesc-ENU; Notice the part fetch_object()->ModelDesc-ENU;- It's an...

Once again: JS functions and objects

javascript,function,object
So I am reading up on JS with Programming JS applications and JS the goodparts. Reading through objects and functions.. which are apparently the same. According to Crockford himself (and practically everybody). But then I ask: if they are the same then why if I have an object: var myObject...

Merging and reordering two arrays of objects

javascript,arrays,object,javascript-objects
I'm trying to figure out how to merge two arrays of objects. Here's what I need to do: field property is the unique identifier of each object Output needs to only have the objects listed in the originalArray Order of localStorageArray needs to be maintained, with attention paid to previous...

Access object variables dynamically in php

php,object
There are multiple response type from my service provider and that is why i created a config array like below. $configArray = array( 'type_1' => array( 'name' => array('parent', 'user', 'profile', 'name', 'fullName') ), 'type_2' => array( 'name' => array('parent', 'person', 'info', 'basic', 'name') ) ); So if the return...

Reading and listing objects in the order they appear in the source file in R

r,sorting,object,ls
I have a file with list of paths to URLs and and files that resembles the extract bellow: urls_queries_files.R url_some_dta <- "url_goes_here" backup_some_dta <- "path to the backup rds file goes here" url_exotic_dta <- "another_url" backup_exotic_dta <- "some backup rds file" url_mysterious_dta <- "url goes here" backup_mysterious_dta <- "backup rds...

Jackson - Extract Data without Brackets, Commas, and =?

java,json,object,jackson,jackson-modules
I don't know a ton about Jackson, I'm just using it because I needed to share data from Python to Java. Anyway my code is pretty simple ObjectMapper mapper = new ObjectMapper(); Map<String,Object> data = mapper.readValue(new File(FileName), Map.class); System.out.println(data.get("SomeInput")); This is what I'm getting: {Y=0.830168776371308, Z=0.16877637130801687, X=0.0010548523206751054} I really just...

How to add key pairs to object literals using loop--WITHOUT overriding existing entries?

javascript,jquery,object,key,literals
I'm reading input field 'name' and 'value' attributes from ul lists. No two lists have the same amount of inputs and the 'name' and 'value' attributes are unknown till read. <ul id="options_set1"> <li><input name="width" value="10" /></li> <li><input name="height" value="20" /></li> <li><input name="depth" value="5" /></li> </ul> <ul id="options_set2"> <li><input name="finish" value="printed"...

Object declaration in C++

c++,object,constructor
I have two questions about the following code in c++. What does the line A obj() in main() mean? Its not giving any error. And why does the next line obj.fun(); give the following error? request for member 'fun' in 'obj', which is of non-class type 'A()' The code is:...

Object (Sprite) in 2D java game moves abnormally

java,eclipse,object
My sprite in my test game flies off screen at super high rates when pressing the key inputs I have and I don't know why. KeyInput.java: package com.cosmicluck.miner.framework; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import com.cosmicluck.miner.window.Handler; public class KeyInput extends KeyAdapter { Handler handler; public KeyInput(Handler handler) { this.handler = handler; }...

Return two separate arrays from an object in JavaSript

javascript,arrays,object
I need to complete the keysAndValues function so that it takes an object and returns the keys and values as separate arrays. For example: keysAndValues({k: 11, l: 12, m: 13}) // should return [['k', 'l', 'm'], [11, 12, 13]] I have already tried: http://jsfiddle.net/marcusdei/ppfh5fpa/4/...

Dynamic creation of objects vs storing them as fields

java,performance,object
I have this loop which runs about 1,000,000 times. while ((line = br.readLine()) != null) { if(!(line.isEmpty())){ data = new JSONObject(line); name = (String)data.get("name"); surname = (String)data.get("surname"); ar.put(name, surname); //an array } } What are the advantages (if any) in terms of efficiency of having it like that were data,name...