Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-26 Thread Sven Van Caekenberghe
n Behalf Of > Markus Böhm > Sent: 24 April 2017 18:42 > To: pharo-users@lists.pharo.org > Subject: [Pharo-users] Hot to retrieve values from Nested Dictionaries > > May I ask: > What's the idiomatic way to retrieve values from nested dictionaries? > > (((dict1 at: 'key1') at: 'key2') at: 'key3') > > Are all the brackets really necessary? > > BR Mike

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-25 Thread PBKResearch
Markus Böhm Sent: 24 April 2017 18:42 To: pharo-users@lists.pharo.org Subject: [Pharo-users] Hot to retrieve values from Nested Dictionaries May I ask: What's the idiomatic way to retrieve values from nested dictionaries? (((dict1 at: 'key1') at: 'key2') at

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-25 Thread Paul DeBruicker
JsonObject has the doesNotUnderstand: trick too. Esteban A. Maringolo wrote > 2017-04-25 8:49 GMT-03:00 Markus Böhm < > markus.boehm@ > >: >> Tx, I tried Your proposal. Just as an example, it works: > >> P.S.: Editor in Playground shows NeoJSONObject keys in red color? > > It's highlight

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-25 Thread Esteban A. Maringolo
2017-04-25 8:49 GMT-03:00 Markus Böhm : > Tx, I tried Your proposal. Just as an example, it works: > P.S.: Editor in Playground shows NeoJSONObject keys in red color? It's highlighted in red because for the playground the keys are selectors not implemented by any class in the image. The key in

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-25 Thread Markus Böhm
Tx, I tried Your proposal. Just as an example, it works: (ZnClient new url: 'http://api.wunderground.com/api/APIKEY/hourly/q/germany/munich.json '; contentReader: [ :entity | (NeoJSONReader on: entity readStream) mapClass: NeoJSONObject; propertyNamesAsSymbols: true;

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Esteban A. Maringolo
2017-04-24 16:10 GMT-03:00 Ramon Leon : > On 04/24/2017 11:16 AM, Esteban A. Maringolo wrote:> >> For these use cases it >> would be nice to have some sort of syntax sugar >> as with the cascade operator, but with a chaining operator instead. > This doesn't even require syntactic sugar, just objec

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Ramon Leon
On 04/24/2017 11:16 AM, Esteban A. Maringolo wrote:> For these use cases it would be nice to have some sort of syntax sugar as with the cascade operator, but with a chaining operator instead. This doesn't even require syntactic sugar, just objects, and this is a more general problem even with

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Udo Schneider
If you are using NeoJSON you might want to take a look at the NeoJSONObject class. It's basically a Dictionary with "JavaScript" behavior. I.e. you can simply use messages to access keys and non existing keys return nil. Your example can thus be written as: val := dict1 key1 key2 key3. When us

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Peter Uhnak
Maybe we could introduce `@` message, so one can chain them and then even execute keyword without parenthesis Dictionary>>@ aKey ^ at: aKey dict @ 'key1' @ 'key2' @ 'key3' dict @ 'key1' @ 'key2' @ 'key3' select: [ :each | ... ] I'm always adding this when hacking around, maybe we could

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Esteban A. Maringolo
For these use cases it would be nice to have some sort of syntax sugar as with the cascade operator, but with a chaining operator instead. The chaining operator would send the message to the result of the previous statement instead of the original receiver as in the semicolon cascade operator (;).

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Markus Böhm
Tx for advice. P.S.: I got nested dictionaries after JSON API call at wunderground weather API. To see all the response in Pharo inspector "live" is really great :-) BR Mike On Mon, Apr 24, 2017 at 7:51 PM, Cyril Ferlicot D. wrote: > Le 24/04/2017 à 19:42, Markus Böhm a écrit : > > May I ask:

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Cyril Ferlicot D.
Le 24/04/2017 à 19:42, Markus Böhm a écrit : > May I ask: > What's the idiomatic way to retrieve values from nested dictionaries? > > (((dict1 at: 'key1') at: 'key2') at: 'key3') > > Are all the brackets really necessary? > > BR Mike Hi, To know if brackets are necessary you can use the "Forma

Re: [Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Juraj Kubelka
> On Apr 24, 2017, at 14:42, Markus Böhm wrote: > > May I ask: > What's the idiomatic way to retrieve values from nested dictionaries? > > (((dict1 at: 'key1') at: 'key2') at: 'key3') > > Are all the brackets really necessary? I think so, without the parenthesis, it is interpreted as one mess

[Pharo-users] Hot to retrieve values from Nested Dictionaries

2017-04-24 Thread Markus Böhm
May I ask: What's the idiomatic way to retrieve values from nested dictionaries? (((dict1 at: 'key1') at: 'key2') at: 'key3') Are all the brackets really necessary? BR Mike