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 = { ‘mydict2’: { ‘val’: … } } 33 Answers 33 I’ve always kept this around … Read more

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 select statement create a result set which the outer SELECT statement then queries? 2 Answers 2

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’ }, ‘part3’ : [ { ‘name’: ‘Part 3A’, ‘size’: ’10’, ‘qty’ : ’20’ }, { ‘name’: ‘Part 3B’, ‘size’: ‘5’, … Read more

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 nested objects? alert(test.level1); yields undefined, but alert(test.level1.level2.level3); fails. I’m currently doing something like this: … Read more

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’ }, { id: 2, name: ‘bar’ }] }; How could I access the name of the … Read more