Search code examples
javascriptarraysdictionarygoogle-chrome-appgoogle-nativeclient

How to receive array within Vardictonary in Native Client send from javascript


I am sending dictionary with string and array from javascript to native client like

   var paramdata=[]  //with values

   common.naclModule.postMessage({'message' : 'Configuration',
                                 'param_array' : paramdata});

and trying to receive from native client like

    if (var_message.is_dictionary()) {
     pp::VarArray param_array;
       pp::VarDictionary dictionary_js(var_message);
       std::string js_message = dictionary_js.Get("message").AsString();
       if(js_message == "Configuration")
       {
                pp::Var var(dictionary_js.Get("param_array"));

but it gives error like error: no match for call to `(pp::VarArray) (pp::Var&)'...what is the proper way to get array from dictionary. Thanks in advance.


Solution

  • I got an answer.. I have to use

    pp::VarArray array = dictionary_js.Get("param_array");
    

    instead of

    pp::Var var(dictionary_js.Get("param_array"));