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;

        next ];

  get ) hourly_forecast collect: [:e | e FCTTIME hour_padded asInteger ]



P.S.: Editor in Playground shows NeoJSONObject keys in red color?

Am 24.04.2017 9:00 nachm. schrieb "Udo Schneider" <
udo.schnei...@homeaddress.de>:

> 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 using NeoJSON you can simply configure your Mapper (Reader/Writer) to
> use NeoJSONObject using #mapClass:
>
> CU,
>
> Udo
>
>
> On 24/04/2017 20:04, Markus Böhm wrote:
>
>> 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. <
>> cyril.ferli...@gmail.com <mailto:cyril.ferli...@gmail.com>> wrote:
>>
>>     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 "Format" option in
>>     your method.
>>
>>     Right click -> format
>>
>>     or cmd/alt/ctrl + shift + f
>>
>>     In this case you can just write:
>>
>>     ((dict1 at: 'key1') at: 'key2') at: 'key3'.
>>
>>
>>
>>     --
>>     Cyril Ferlicot
>>     https://ferlicot.fr
>>
>>     http://www.synectique.eu
>>     2 rue Jacques Prévert 01,
>>     59650 Villeneuve d'ascq France
>>
>>
>>
>
>
>

Reply via email to