Correct version:

[Emit(proplists:get_value(<<"id">>, Campaign, null), {Campaign}) || {Campaign} 
<- AdwordsCampaigns];

But you get the idea.

On May 11, 2010, at 3:23 PM, Adam Kocoloski wrote:

> Hi Mike, are you sure this is what you want?
> 
>>     [Emit(proplists:get_value(<<"id">>, StrippedCampaign, null), Campaign) 
>> || Campaign <- AdwordsCampaigns, {StrippedCampaign} <- AdwordsCampaigns];
> 
> Try it in the emulator
> 
> 1> Foo = [1,2,3].
> [1,2,3]
> 2> [{X,Y} || Y <- Foo, X <- Foo].
> [{1,1},{2,1},{3,1},{1,2},{2,2},{3,2},{1,3},{2,3},{3,3}]
> 
> You're generating combinatoric pairs of all elements of AdwordsCampaigns, 
> pulling the key from the first element of the pair and the value from the 
> second part of the pair.  Perhaps you're looking for this instead?
> 
> [Emit(proplists:get_value(<<"id">>, Campaign, null), {Campaign}) || Campaign 
> <- AdwordsCampaigns];
> 
> Best, Adam
> 
> On May 11, 2010, at 2:58 PM, Mike Keen wrote:
> 
>> You're right. In the value column, the id shows up as 50573744 which is the 
>> correct value. In the key column, it shows up as 53518364.
>> 
>> On May 11, 2010, at 2:44 PM, Randall Leeds wrote:
>> 
>>> On Tue, May 11, 2010 at 11:40, Jarrod Roberson <[email protected]> 
>>> wrote:
>>>> On Tue, May 11, 2010 at 2:31 PM, Mike Keen <[email protected]> wrote:
>>>> 
>>>>> I guess I'm confused as to why JavaScript is ever even involved when
>>>>> writing views in Erlang. Excuse my ignorance, but does all JSON go through
>>>>> it?
>>>>> 
>>>>> Mike
>>>>> 
>>>>> read all the comments to that bug report, it is the JSON parser that
>>>> conforms to the limitations of JavaScript. And everything goes thru the 
>>>> JSON
>>>> parser.
>>>> 
>>> 
>>> I think we're missing the point. Even if the erlang JSON parser
>>> conforms to JSON's notion of numbers then I'd expect the id to be
>>> transformed the same way for both the key and the value.
>>> 
>>> Maybe the key is implicitly treated as a string? Mike, which is the
>>> "correct" value for the id?
>> 
> 

Reply via email to