value.key not working for passed json inside map function

Venki Yedidha venkatesh.yedidha at gmail.com
Thu Aug 23 03:03:52 EDT 2012


Hi All,

       I have a map function which takes inputs for all countries:
       my bucket format is
[["20120822","IN"],["20120822","IS"],["20120822","CN"],["20120822","US"],["20120822","AS"],["20120822","JP"]]

      my json format is :

 $m=    ' {
    "IN": {
        "Internetusers": "12816",
        "population": "193161"
    },
    "IS": {
        "Internetusers": "26907",
        "population": "571890"
    },
    "CN": {
        "Internetusers": "800",
        "population": "1384"
    },
    "US": {
        "Internetusers": "12487",
        "population": "105916"
    },
    "AS": {
        "Internetusers": "12487",
        "population": "105916"
    },
    "JP": {
        "Internetusers": "12487",
        "population": "105916"
    }
}';
$m = addslashes($m); //this just adds \ infront of " to escape double
quotes.



Now I am accessing this inside a map function written in javascript(my
server side script is php),like:
   var k = '.$m.';
   when I am trying to access k[value.key], it throws an error saying
k[value.key][\"Internetusers\"] is undefined..
   On the other hand, giving a static value works fine for me..
  like k[\"JP\"][\"Internetusers\"] works fine....

I thought k[value.key] should work fine because my bucket keys and my json
keys are same...

I tried all these types.

k[value.key],k[\"'.value.key.'\"],k[\"'+value.key.+\"] etc

Please help on the above,

Thanks,
Venkatesh.Y
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120823/805c0e69/attachment.html>


More information about the riak-users mailing list