It looks like mochijson2 has an assumption that anything that looks
like a proplist (a list of 2-tuples) gets turned into a hash.
7> list_to_binary(mochijson2:encode([{a , b}, {foo, bar}])).
<<"{\"a\":\"b\",\"foo\":\"bar\"}">>
This is likely something that should be documented, but it doesn't
seem fixable, at least on the MR side, as JSON has no 'tuple' notion.
A workaround for the time being would be to use a list of length-2
lists.
Clients should probably not explode on seeing this.
On Wed, Dec 19, 2012 at 2:36 PM, Elias Levy <[email protected]> wrote:
> Resending as I did not get a response from Basho folks.
>
> Is this expected behavior?
>
>
>
> On Fri, Dec 14, 2012 at 5:08 PM, Elias Levy <[email protected]>
> wrote:
>>
>> It appears that the Riak MR API can on occasions return a JSON Object,
>> rather than an Array. This blows up the Ruby client, and I am guessing
>> probably some other ones. I've opened an issue for the Ruby client. See
>> https://github.com/basho/riak-ruby-client/issues/67.
>>
>> I came across the issue while writing an Erlang map phase function to bulk
>> fetch values while returning their key. The function is:
>>
>> map_object_key_value({error, notfound}, _, _) -> [];
>> map_object_key_value(RiakObject, _, _) ->
>> [{ riak_object:key(RiakObject), riak_object:get_value(RiakObject) }].
>>
>> It appears that Riak (or mochijson2?) will convert an array of 2 tuples
>> into a JSON hash when returning the data.
>>
>> This is actually quite nice, at least for this application, as its exactly
>> what I want, but it seems is either undocumented or a bug, since clients do
>> not respond well to it.
>>
>> Thoughts?
>>
>> Elias Levy
>
>
>
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com