Questions tagged [nested]

This tag relates to any of various nested entities or operations in programming.

This tag relates to any of various nested entities in programming, including but not limited to:

  • Nested data structures
  • Nested queries
  • Nested calls to a procedure, subroutine, method or operation

For example, nesting queries in SQL means to create a subquery. Its result is used in the query itself and provides a query order and subsets.


Related tags :

14133 questions
962
votes
28 answers

How can I access and process nested objects, arrays or JSON?

I have a nested data structure containing objects and arrays. How can I extract the information, i.e. access a specific or multiple values (or keys)? For example: var data = { code: 42, items: [{ id: 1, name: 'foo' }, { …
Felix Kling
  • 705,106
  • 160
  • 1,004
  • 1,072
765
votes
60 answers

Test for existence of nested JavaScript object key

If I have a reference to an object: var test = {}; that will potentially (but not immediately) have nested objects, something like: {level1: {level2: {level3: "level3"}}}; What is the best way to check for the existence of property in deeply…
user113716
  • 299,514
  • 60
  • 431
  • 433
519
votes
41 answers

Accessing nested JavaScript objects and arrays by string path

I have a data structure like this : var someObject = { 'part1' : { 'name': 'Part 1', 'size': '20', 'qty' : '50' }, 'part2' : { 'name': 'Part 2', 'size': '15', 'qty' : '60' }, …
Komaruloh
  • 5,303
  • 3
  • 13
  • 7
449
votes
14 answers

Margin on child element moves parent element

I have a div (parent) that contains another div (child). Parent is the first element in body with no particular CSS style. When I set .child { margin-top: 10px; } The end result is that top of my child is still aligned with parent. Instead of…
Robert Koritnik
  • 97,460
  • 50
  • 267
  • 388
424
votes
2 answers

Nested select statement in SQL Server

Why doesn't the following work? SELECT name FROM (SELECT name FROM agentinformation) I guess my understanding of SQL is wrong, because I would have thought this would return the same thing as SELECT name FROM agentinformation Doesn't the inner…
Brennan Vincent
  • 9,595
  • 9
  • 28
  • 50
344
votes
27 answers

How to use a dot "." to access members of dictionary?

How do I make Python dictionary members accessible via a dot "."? For example, instead of writing mydict['val'], I'd like to write mydict.val. Also I'd like to access nested dicts this way. For example mydict.mydict2.val would refer to mydict = {…
bodacydo
  • 63,809
  • 83
  • 206
  • 303
324
votes
11 answers

Nested routes with react router v4 / v5

I am currently struggling with nesting routes using react router v4. The closest example was the route config in the React-Router v4 Documentation. I want to split my app in 2 different parts. A frontend and an admin area. I was thinking about…
datoml
  • 4,594
  • 3
  • 17
  • 27
258
votes
12 answers

List comprehension on a nested list?

I have this nested list: l = [['40', '20', '10', '30'], ['20', '20', '20', '20', '20', '30', '20'], ['30', '20', '30', '50', '10', '30', '20', '20', '20'], ['100', '100'], ['100', '100', '100', '100', '100'], ['100', '100', '100', '100']] Now, what…
Boy Pasmo
  • 6,923
  • 9
  • 35
  • 55
233
votes
3 answers

How to query nested objects?

I have a problem when querying mongoDB with nested objects notation: db.messages.find( { headers : { From: "reservations@marriott.com" } } ).count() 0 db.messages.find( { 'headers.From': "reservations@marriott.com" } ).count() 5 I can't see what I…
Edmondo1984
  • 17,841
  • 12
  • 55
  • 99
231
votes
11 answers

Can regular expressions be used to match nested patterns?

Is it possible to write a regular expression that matches a nested pattern that occurs an unknown number of times? For example, can a regular expression match an opening and closing brace when there are an unknown number of open/close braces nested…
Richard Dorman
  • 21,020
  • 12
  • 42
  • 48
214
votes
7 answers

Forward declaration of nested types/classes in C++

I recently got stuck in a situation like this: class A { public: typedef struct/class {…} B; … C::D *someField; } class C { public: typedef struct/class {…} D; … A::B *someField; } Usually you can declare a class name: class…
Calmarius
  • 16,155
  • 15
  • 95
  • 134
203
votes
5 answers

Why would one use nested classes in C++?

Can someone please point me towards some nice resources for understanding and using nested classes? I have some material like Programming Principles and things like this IBM Knowledge Center - Nested Classes But I'm still having trouble…
bespectacled
  • 2,441
  • 4
  • 23
  • 30
202
votes
16 answers

How do you overcome the HTML form nesting limitation?

I know that XHTML doesn't support nested form tags and I have already read other answers here on Stack Overflow regarding this subject, but I still haven't figured out an elegant solution to the problem. Some say you don't need it and that they…
gCoder
  • 2,045
  • 2
  • 13
  • 5
196
votes
9 answers

Best way to do nested case statement logic in SQL Server

I'm writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions. I'm currently using nested case statements, but its getting messy. Is there a better (more organised and/or readable) way? (I…
Sophia
  • 5,253
  • 9
  • 35
  • 43
195
votes
7 answers

Can you create nested WITH clauses for Common Table Expressions?

WITH y AS ( WITH x AS ( SELECT * FROM MyTable ) SELECT * FROM x ) SELECT * FROM y Does something like this work? I tried it earlier but I couldn't get it to work.
Joe Phillips
  • 44,686
  • 25
  • 93
  • 148
1
2 3
99 100